OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 import sys | 8 import sys |
9 import unittest | 9 import unittest |
10 | 10 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 def test_call_timeout_no_kill_eol(self): | 92 def test_call_timeout_no_kill_eol(self): |
93 cmd = [sys.executable, SLEEP, '0.001'] | 93 cmd = [sys.executable, SLEEP, '0.001'] |
94 output, code = run_test_cases.call_with_timeout( | 94 output, code = run_test_cases.call_with_timeout( |
95 cmd, timeout=100, universal_newlines=True) | 95 cmd, timeout=100, universal_newlines=True) |
96 self.assertEquals('Sleeping.\nSlept.\n', output) | 96 self.assertEquals('Sleeping.\nSlept.\n', output) |
97 self.assertEquals(0, code) | 97 self.assertEquals(0, code) |
98 | 98 |
99 def test_gtest_filter(self): | 99 def test_gtest_filter(self): |
100 old = run_test_cases.run_test_cases | 100 old = run_test_cases.run_test_cases |
101 exe = os.path.join(ROOT_DIR, 'data', 'gtest_fake', 'gtest_fake_pass.py') | 101 exe = os.path.join(ROOT_DIR, 'data', 'gtest_fake', 'gtest_fake_pass.py') |
102 def expect(executable, test_cases, jobs, timeout, no_dump): | 102 def expect(executable, test_cases, jobs, timeout, result_file): |
103 self.assertEquals(exe, executable) | 103 self.assertEquals(exe, executable) |
104 self.assertEquals(['Foo.Bar1', 'Foo.Bar3'], test_cases) | 104 self.assertEquals(['Foo.Bar1', 'Foo.Bar3'], test_cases) |
105 self.assertEquals(run_test_cases.num_processors(), jobs) | 105 self.assertEquals(run_test_cases.num_processors(), jobs) |
106 self.assertEquals(120, timeout) | 106 self.assertEquals(120, timeout) |
107 self.assertEquals(None, no_dump) | 107 self.assertEquals(exe + '.run_test_cases', result_file) |
108 return 89 | 108 return 89 |
109 try: | 109 try: |
110 run_test_cases.run_test_cases = expect | 110 run_test_cases.run_test_cases = expect |
111 result = run_test_cases.main([exe, '--gtest_filter=Foo.Bar*-*.Bar2']) | 111 result = run_test_cases.main([exe, '--gtest_filter=Foo.Bar*-*.Bar2']) |
112 self.assertEquals(89, result) | 112 self.assertEquals(89, result) |
113 finally: | 113 finally: |
114 run_test_cases.run_test_cases = old | 114 run_test_cases.run_test_cases = old |
115 | 115 |
116 | 116 |
117 class WorkerPoolTest(unittest.TestCase): | 117 class WorkerPoolTest(unittest.TestCase): |
(...skipping 18 matching lines...) Expand all Loading... |
136 pool.join() | 136 pool.join() |
137 self.fail() | 137 self.fail() |
138 except FearsomeException: | 138 except FearsomeException: |
139 self.assertEquals(True, task_added) | 139 self.assertEquals(True, task_added) |
140 | 140 |
141 | 141 |
142 if __name__ == '__main__': | 142 if __name__ == '__main__': |
143 VERBOSE = '-v' in sys.argv | 143 VERBOSE = '-v' in sys.argv |
144 logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR) | 144 logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR) |
145 unittest.main() | 145 unittest.main() |
OLD | NEW |