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 json | 6 import json |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import re | 9 import re |
10 import subprocess | 10 import subprocess |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 ('Foo.Bar2', 1), | 98 ('Foo.Bar2', 1), |
99 ('Foo.Bar3', 1) | 99 ('Foo.Bar3', 1) |
100 ] | 100 ] |
101 self._check_results_file(expected_result_file_entries) | 101 self._check_results_file(expected_result_file_entries) |
102 | 102 |
103 def test_simple_fail(self): | 103 def test_simple_fail(self): |
104 out, err, return_code = RunTest('gtest_fake_fail.py', self.filename) | 104 out, err, return_code = RunTest('gtest_fake_fail.py', self.filename) |
105 | 105 |
106 self.assertEquals(1, return_code) | 106 self.assertEquals(1, return_code) |
107 | 107 |
108 test_fail_output = [ | 108 expected_out_re = [ |
| 109 r'\[\d/\d\] \d\.\d\ds .+', |
| 110 r'\[\d/\d\] \d\.\d\ds .+', |
| 111 r'\[\d/\d\] \d\.\d\ds .+', |
| 112 r'\[\d/\d\] \d\.\d\ds .+', |
| 113 r'\[\d/\d\] \d\.\d\ds .+', |
| 114 r'\[\d/\d\] \d\.\d\ds .+', |
109 re.escape('Note: Google Test filter = Baz.Fail'), | 115 re.escape('Note: Google Test filter = Baz.Fail'), |
110 r'', | 116 r'', |
111 ] + [ | 117 ] + [ |
112 re.escape(l) for l in | 118 re.escape(l) for l in |
113 gtest_fake_base.get_test_output('Baz.Fail').splitlines() | 119 gtest_fake_base.get_test_output('Baz.Fail').splitlines() |
114 ] + [ | 120 ] + [ |
115 '', | 121 '', |
116 ] + [ | 122 ] + [ |
117 re.escape(l) for l in gtest_fake_base.get_footer(1, 1).splitlines() | 123 re.escape(l) for l in gtest_fake_base.get_footer(1, 1).splitlines() |
118 ] + [ | 124 ] + [ |
119 '' | 125 '', |
120 ] | |
121 | |
122 expected_out_re = [ | |
123 r'\[\d/\d\] \d\.\d\ds .+', | |
124 r'\[\d/\d\] \d\.\d\ds .+', | |
125 r'\[\d/\d\] \d\.\d\ds .+', | |
126 r'\[\d/\d\] \d\.\d\ds .+', | |
127 r'\[\d/\d\] \d\.\d\ds .+', | |
128 r'\[\d/\d\] \d\.\d\ds .+', | |
129 ] + test_fail_output + [ | |
130 re.escape('Retrying failed tests serially.'), | |
131 r'\[\d/\d\] \d\.\d\ds .+', | |
132 ] + test_fail_output + [ | |
133 re.escape('Summary:'), | 126 re.escape('Summary:'), |
134 re.escape('Baz.Fail failed'), | 127 re.escape('Baz.Fail failed'), |
135 re.escape('Success: 3 75.00%'), | 128 re.escape('Success: 3 75.00%'), |
136 re.escape('Flaky: 0 0.00%'), | 129 re.escape('Flaky: 0 0.00%'), |
137 re.escape('Fail: 1 25.00%'), | 130 re.escape('Fail: 1 25.00%'), |
138 r'\d+\.\ds Done running 4 tests with 6 executions. \d+\.\d test/s', | 131 r'\d+\.\ds Done running 4 tests with 6 executions. \d+\.\d test/s', |
139 ] | 132 ] |
140 self._check_results(expected_out_re, out, err) | 133 self._check_results(expected_out_re, out, err) |
141 | 134 |
142 expected_result_file_entries = [ | 135 expected_result_file_entries = [ |
143 ('Foo.Bar1', 1), | 136 ('Foo.Bar1', 1), |
144 ('Foo.Bar2', 1), | 137 ('Foo.Bar2', 1), |
145 ('Foo.Bar3', 1), | 138 ('Foo.Bar3', 1), |
146 ('Baz.Fail', 4) | 139 ('Baz.Fail', 3) |
147 ] | 140 ] |
148 self._check_results_file(expected_result_file_entries) | 141 self._check_results_file(expected_result_file_entries) |
149 | 142 |
150 def test_simple_gtest_list_error(self): | 143 def test_simple_gtest_list_error(self): |
151 out, err, return_code = RunTest('gtest_fake_error.py') | 144 out, err, return_code = RunTest('gtest_fake_error.py') |
152 | 145 |
153 expected_out_re = [ | 146 expected_out_re = [ |
154 'Failed to run .+gtest_fake_error.py', | 147 'Failed to run .+gtest_fake_error.py', |
155 'Unable to list tests' | 148 'Unable to list tests' |
156 ] | 149 ] |
157 | 150 |
158 self.assertEqual(1, return_code) | 151 self.assertEqual(1, return_code) |
159 self._check_results(expected_out_re, out, err) | 152 self._check_results(expected_out_re, out, err) |
160 | 153 |
161 | 154 |
162 if __name__ == '__main__': | 155 if __name__ == '__main__': |
163 VERBOSE = '-v' in sys.argv | 156 VERBOSE = '-v' in sys.argv |
164 logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR) | 157 logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR) |
165 unittest.main() | 158 unittest.main() |
OLD | NEW |