Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(620)

Unified Diff: testing_support/tests/thread_watcher_test.py

Issue 2127943002: Thread Watcher: don't fail when test already failed. (Closed) Base URL: https://chromium.googlesource.com/infra/testing/testing_support.git@master
Patch Set: Test. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | testing_support/thread_watcher.py » ('j') | testing_support/thread_watcher.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testing_support/tests/thread_watcher_test.py
diff --git a/testing_support/tests/thread_watcher_test.py b/testing_support/tests/thread_watcher_test.py
index 4989f2d8311a5625b9b4c84ef36e9bff95057875..d1aa12076985cbb1ed6f3ece2fc8527419e2cdf7 100644
--- a/testing_support/tests/thread_watcher_test.py
+++ b/testing_support/tests/thread_watcher_test.py
@@ -28,6 +28,13 @@ class _PuppetThread(threading.Thread):
self._stop_event.set()
self.join()
+class _ResultFake(object):
+ def __init__(self, value):
+ self.value = value
+
+ def wasSuccessful(self):
+ return self.value
+
class ThreadWatcherTestCase(thread_watcher.TestCase):
def setUp(self):
@@ -71,6 +78,38 @@ class ThreadWatcherTestCase(thread_watcher.TestCase):
self.assertNotIn(' Thread stopped while acquiring stacktrace.\n',
error_message)
+ def test_extra_threads_unittest_pass(self):
+ # Test succeeded, so thread_watcher must cause failure.
+ self.watcher._resultForDoCleanups = _ResultFake(True)
+ self.watcher.setUp()
+ self._threads.append(_PuppetThread('foo'))
+ self.watcher.tearDown()
+ self.assertEqual(len(self._fail_called), 1)
+
+ def test_extra_threads_unittest_pass(self):
Michael Achenbach 2016/07/07 12:30:41 Same method signature as the method above? Also th
tandrii(chromium) 2016/07/07 12:56:39 Done.
+ # Test failed already, so thread_watcher must ignore result.
+ self.watcher._resultForDoCleanups = _ResultFake(False)
+ self.watcher.setUp()
+ self._threads.append(_PuppetThread('foo'))
+ self.watcher.tearDown()
+ self.assertEqual(self._fail_called, [])
+
+ def test_extra_threads_expect_tests_pass(self):
+ # Test succeeded, so thread_watcher must cause failure.
+ self.watcher._test_failed_with_exception = False
+ self.watcher.setUp()
+ self._threads.append(_PuppetThread('foo'))
+ self.watcher.tearDown()
+ self.assertEqual(len(self._fail_called), 1)
+
+ def test_extra_threads_expect_tests_pass(self):
+ # Test failed already, so thread_watcher must ignore result.
+ self.watcher._test_failed_with_exception = True
+ self.watcher.setUp()
+ self._threads.append(_PuppetThread('foo'))
+ self.watcher.tearDown()
+ self.assertEqual(self._fail_called, [])
+
def test_fail_get_stacktrace(self):
self.watcher.setUp()
self._threads.append(_PuppetThread('foo'))
« no previous file with comments | « no previous file | testing_support/thread_watcher.py » ('j') | testing_support/thread_watcher.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698