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

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: review 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') | no next file with comments »
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..c98be29c985bd74a1b8ef5f086c3847b174c30c3 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_fail(self):
+ # 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_fail(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'))
@@ -108,6 +147,5 @@ class ThreadWatcherTestCaseUsageTest(thread_watcher.TestCase):
self._threads[-1].stop()
-
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « no previous file | testing_support/thread_watcher.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698