| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Unittests for shard.py.""" | 5 """Unittests for shard.py.""" |
| 6 | 6 |
| 7 import os | 7 import os |
| 8 import sys | 8 import sys |
| 9 import unittest | 9 import unittest |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 class TestWorker(unittest.TestCase): | 46 class TestWorker(unittest.TestCase): |
| 47 """Tests for shard._Worker.""" | 47 """Tests for shard._Worker.""" |
| 48 @staticmethod | 48 @staticmethod |
| 49 def _RunRunner(mock_runner, tests): | 49 def _RunRunner(mock_runner, tests): |
| 50 results = [] | 50 results = [] |
| 51 retry = [] | 51 retry = [] |
| 52 worker = shard._Worker(mock_runner, tests, results, retry) | 52 worker = shard._Worker(mock_runner, tests, results, retry) |
| 53 worker.start() | 53 worker.start() |
| 54 worker.join() | 54 worker.join() |
| 55 worker.Reraise() | 55 worker.ReraiseIfException() |
| 56 return (results, retry) | 56 return (results, retry) |
| 57 | 57 |
| 58 def testRun(self): | 58 def testRun(self): |
| 59 results, retry = TestWorker._RunRunner(MockRunner(), ['a', 'b']) | 59 results, retry = TestWorker._RunRunner(MockRunner(), ['a', 'b']) |
| 60 self.assertEqual(len(results), 2) | 60 self.assertEqual(len(results), 2) |
| 61 self.assertEqual(len(retry), 0) | 61 self.assertEqual(len(retry), 0) |
| 62 | 62 |
| 63 def testRetry(self): | 63 def testRetry(self): |
| 64 results, retry = TestWorker._RunRunner(MockRunnerRetry(), ['a', 'b']) | 64 results, retry = TestWorker._RunRunner(MockRunnerRetry(), ['a', 'b']) |
| 65 self.assertEqual(len(results), 2) | 65 self.assertEqual(len(results), 2) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 self.assertEqual(len(results.ok), 3) | 107 self.assertEqual(len(results.ok), 3) |
| 108 | 108 |
| 109 def testFailing(self): | 109 def testFailing(self): |
| 110 results = TestShard._RunShard(MockRunnerRetry) | 110 results = TestShard._RunShard(MockRunnerRetry) |
| 111 self.assertEqual(len(results.ok), 0) | 111 self.assertEqual(len(results.ok), 0) |
| 112 self.assertEqual(len(results.failed), 3) | 112 self.assertEqual(len(results.failed), 3) |
| 113 | 113 |
| 114 | 114 |
| 115 if __name__ == '__main__': | 115 if __name__ == '__main__': |
| 116 unittest.main() | 116 unittest.main() |
| OLD | NEW |