| 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 """Unit tests for classes in gtest_command.py.""" | 6 """Unit tests for classes in gtest_command.py.""" |
| 7 | 7 |
| 8 import unittest | 8 import unittest |
| 9 | 9 |
| 10 import test_env # pylint: disable=W0611 | 10 import test_env # pylint: disable=W0611 |
| 11 | 11 |
| 12 from common import gtest_utils | 12 from common import gtest_utils |
| 13 | 13 |
| 14 | 14 |
| 15 FAILURES = ['NavigationControllerTest.Reload', | 15 FAILURES = ['NavigationControllerTest.Reload', |
| 16 'NavigationControllerTest/SpdyNetworkTransTest.Constructor/0', | 16 'NavigationControllerTest/SpdyNetworkTransTest.Constructor/0', |
| 17 'BadTest.TimesOut', | 17 'BadTest.TimesOut', |
| 18 'MoreBadTest.TimesOutAndFails', | 18 'MoreBadTest.TimesOutAndFails', |
| 19 'SomeOtherTest.SwitchTypes'] | 19 'SomeOtherTest.SwitchTypes', |
| 20 'SomeOtherTest.FAILS_ThisTestTimesOut'] |
| 20 | 21 |
| 21 FAILS_FAILURES = ['SomeOtherTest.FAILS_Bar'] | 22 FAILS_FAILURES = ['SomeOtherTest.FAILS_Bar'] |
| 22 FLAKY_FAILURES = ['SomeOtherTest.FLAKY_Baz'] | 23 FLAKY_FAILURES = ['SomeOtherTest.FLAKY_Baz'] |
| 23 | 24 |
| 24 TIMEOUT_MESSAGE = 'Killed (timed out).' | 25 TIMEOUT_MESSAGE = 'Killed (timed out).' |
| 25 | 26 |
| 26 RELOAD_ERRORS = ('C:\b\slave\chrome-release-snappy\build\chrome\browser' | 27 RELOAD_ERRORS = ('C:\b\slave\chrome-release-snappy\build\chrome\browser' |
| 27 '\navigation_controller_unittest.cc:381: Failure' + """ | 28 '\navigation_controller_unittest.cc:381: Failure' + """ |
| 28 Value of: -1 | 29 Value of: -1 |
| 29 Expected: contents->controller()->GetPendingEntryIndex() | 30 Expected: contents->controller()->GetPendingEntryIndex() |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 [ RUN ] MoreBadTest.TimesOutAndFails | 109 [ RUN ] MoreBadTest.TimesOutAndFails |
| 109 %(morebad_errors)s | 110 %(morebad_errors)s |
| 110 """ % {'morebad_errors': MOREBAD_ERRORS} + | 111 """ % {'morebad_errors': MOREBAD_ERRORS} + |
| 111 '[0531/042642:ERROR:/b/slave/chromium-rel-mac-builder/build/src/chrome/test' | 112 '[0531/042642:ERROR:/b/slave/chromium-rel-mac-builder/build/src/chrome/test' |
| 112 '/test_launcher/out_of_proc_test_runner.cc(79)] Test timeout (30000 ms) ' | 113 '/test_launcher/out_of_proc_test_runner.cc(79)] Test timeout (30000 ms) ' |
| 113 'exceeded for MoreBadTest.TimesOutAndFails' + """ | 114 'exceeded for MoreBadTest.TimesOutAndFails' + """ |
| 114 Handling SIGTERM. | 115 Handling SIGTERM. |
| 115 Successfully wrote to shutdown pipe, resetting signal handler. | 116 Successfully wrote to shutdown pipe, resetting signal handler. |
| 116 [ FAILED ] MoreBadTest.TimesOutAndFails (31000 ms) | 117 [ FAILED ] MoreBadTest.TimesOutAndFails (31000 ms) |
| 117 | 118 |
| 118 [----------] 4 tests from SomeOtherTest | 119 [----------] 5 tests from SomeOtherTest |
| 119 [ RUN ] SomeOtherTest.SwitchTypes | 120 [ RUN ] SomeOtherTest.SwitchTypes |
| 120 %(switch_errors)s | 121 %(switch_errors)s |
| 121 [ FAILED ] SomeOtherTest.SwitchTypes (40 ms) | 122 [ FAILED ] SomeOtherTest.SwitchTypes (40 ms) |
| 122 [ RUN ] SomeOtherTest.Foo | 123 [ RUN ] SomeOtherTest.Foo |
| 123 [ OK ] SomeOtherTest.Foo (20 ms) | 124 [ OK ] SomeOtherTest.Foo (20 ms) |
| 124 [ RUN ] SomeOtherTest.FAILS_Bar | 125 [ RUN ] SomeOtherTest.FAILS_Bar |
| 125 Some error message for a failing test. | 126 Some error message for a failing test. |
| 126 [ FAILED ] SomeOtherTest.FAILS_Bar (40 ms) | 127 [ FAILED ] SomeOtherTest.FAILS_Bar (40 ms) |
| 128 [ RUN ] SomeOtherTest.FAILS_ThisTestTimesOut |
| 129 """ % {'switch_errors' : SWITCH_ERRORS} + |
| 130 '[0521/041343:ERROR:test_launcher.cc(384)] Test timeout (5000 ms) ' |
| 131 'exceeded for SomeOtherTest.FAILS_ThisTestTimesOut' + """ |
| 127 [ RUN ] SomeOtherTest.FLAKY_Baz | 132 [ RUN ] SomeOtherTest.FLAKY_Baz |
| 128 Some error message for a flaky test. | 133 Some error message for a flaky test. |
| 129 [ FAILED ] SomeOtherTest.FLAKY_Baz (40 ms) | 134 [ FAILED ] SomeOtherTest.FLAKY_Baz (40 ms) |
| 130 [----------] 2 tests from SomeOtherTest (60 ms total) | 135 [----------] 2 tests from SomeOtherTest (60 ms total) |
| 131 | 136 |
| 132 [----------] Global test environment tear-down | 137 [----------] Global test environment tear-down |
| 133 [==========] 7 tests from 3 test cases ran. (3750 ms total) | 138 [==========] 8 tests from 3 test cases ran. (3750 ms total) |
| 134 [ PASSED ] 4 tests. | 139 [ PASSED ] 4 tests. |
| 135 [ FAILED ] 3 tests, listed below: | 140 [ FAILED ] 4 tests, listed below: |
| 136 [ FAILED ] NavigationControllerTest.Reload | 141 [ FAILED ] NavigationControllerTest.Reload |
| 137 [ FAILED ] NavigationControllerTest/SpdyNetworkTransTest.Constructor/0 | 142 [ FAILED ] NavigationControllerTest/SpdyNetworkTransTest.Constructor/0 |
| 138 [ FAILED ] SomeOtherTest.SwitchTypes | 143 [ FAILED ] SomeOtherTest.SwitchTypes |
| 144 [ FAILED ] SomeOtherTest.FAILS_ThisTestTimesOut |
| 139 | 145 |
| 140 1 FAILED TEST | 146 1 FAILED TEST |
| 141 YOU HAVE 10 DISABLED TESTS | 147 YOU HAVE 10 DISABLED TESTS |
| 142 | 148 |
| 143 YOU HAVE 2 FLAKY TESTS | 149 YOU HAVE 2 FLAKY TESTS |
| 144 | 150 |
| 145 program finished with exit code 1 | 151 program finished with exit code 1 |
| 146 """ % {'switch_errors' : SWITCH_ERRORS}) | 152 """) |
| 147 | 153 |
| 148 TEST_DATA_CRASH = """ | 154 TEST_DATA_CRASH = """ |
| 149 [==========] Running 7 tests from 3 test cases. | 155 [==========] Running 7 tests from 3 test cases. |
| 150 [----------] Global test environment set-up. | 156 [----------] Global test environment set-up. |
| 151 [----------] 1 test from HunspellTest | 157 [----------] 1 test from HunspellTest |
| 152 [ RUN ] HunspellTest.Crashes | 158 [ RUN ] HunspellTest.Crashes |
| 153 Oops, this test crashed! | 159 Oops, this test crashed! |
| 154 """ | 160 """ |
| 155 | 161 |
| 156 VALGRIND_HASH = 'B254345E4D3B6A00' | 162 VALGRIND_HASH = 'B254345E4D3B6A00' |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 | 231 |
| 226 [----------] 4 tests from SomeOtherTest | 232 [----------] 4 tests from SomeOtherTest |
| 227 [ RUN ] SomeOtherTest.SwitchTypes | 233 [ RUN ] SomeOtherTest.SwitchTypes |
| 228 %(switch_errors)s | 234 %(switch_errors)s |
| 229 [ FAILED ] SomeOtherTest.SwitchTypes (40 ms) | 235 [ FAILED ] SomeOtherTest.SwitchTypes (40 ms) |
| 230 [ RUN ] SomeOtherTest.Foo | 236 [ RUN ] SomeOtherTest.Foo |
| 231 [ OK ] SomeOtherTest.Foo (20 ms) | 237 [ OK ] SomeOtherTest.Foo (20 ms) |
| 232 [ RUN ] SomeOtherTest.FAILS_Bar | 238 [ RUN ] SomeOtherTest.FAILS_Bar |
| 233 Some error message for a failing test. | 239 Some error message for a failing test. |
| 234 [ FAILED ] SomeOtherTest.FAILS_Bar (40 ms) | 240 [ FAILED ] SomeOtherTest.FAILS_Bar (40 ms) |
| 241 [ RUN ] SomeOtherTest.FAILS_ThisTestTimesOut |
| 242 """ % {'switch_errors' : SWITCH_ERRORS} + |
| 243 '[0521/041343:ERROR:test_launcher.cc(384)] Test timeout (5000 ms) exceeded ' |
| 244 'for SomeOtherTest.FAILS_ThisTestTimesOut' + """ |
| 235 [ RUN ] SomeOtherTest.FLAKY_Baz | 245 [ RUN ] SomeOtherTest.FLAKY_Baz |
| 236 Some error message for a flaky test. | 246 Some error message for a flaky test. |
| 237 [ FAILED ] SomeOtherTest.FLAKY_Baz (40 ms) | 247 [ FAILED ] SomeOtherTest.FLAKY_Baz (40 ms) |
| 238 [----------] 2 tests from SomeOtherTest (60 ms total) | 248 [----------] 2 tests from SomeOtherTest (60 ms total) |
| 239 | 249 |
| 240 [----------] Global test environment tear-down | 250 [----------] Global test environment tear-down |
| 241 [==========] 6 tests from 3 test cases ran. (3750 ms total) | 251 [==========] 7 tests from 3 test cases ran. (3750 ms total) |
| 242 [ PASSED ] 5 tests. | 252 [ PASSED ] 5 tests. |
| 243 [ FAILED ] 1 test, listed below: | 253 [ FAILED ] 2 test, listed below: |
| 244 [ FAILED ] SomeOtherTest.SwitchTypes | 254 [ FAILED ] SomeOtherTest.SwitchTypes |
| 255 [ FAILED ] SomeOtherTest.FAILS_ThisTestTimesOut |
| 245 | 256 |
| 246 1 FAILED TEST | 257 1 FAILED TEST |
| 247 YOU HAVE 10 DISABLED TESTS | 258 YOU HAVE 10 DISABLED TESTS |
| 248 | 259 |
| 249 YOU HAVE 2 FLAKY TESTS | 260 YOU HAVE 2 FLAKY TESTS |
| 250 """ % {'switch_errors' : SWITCH_ERRORS}) | 261 """) |
| 251 | 262 |
| 252 TEST_DATA_SHARD_1 = ("""Note: This is test shard 13 of 30. | 263 TEST_DATA_SHARD_1 = ("""Note: This is test shard 13 of 30. |
| 253 [==========] Running 5 tests from 2 test cases. | 264 [==========] Running 5 tests from 2 test cases. |
| 254 [----------] Global test environment set-up. | 265 [----------] Global test environment set-up. |
| 255 [----------] 4 tests from NavigationControllerTest | 266 [----------] 4 tests from NavigationControllerTest |
| 256 [ RUN ] NavigationControllerTest.Defaults | 267 [ RUN ] NavigationControllerTest.Defaults |
| 257 [ OK ] NavigationControllerTest.Defaults (48 ms) | 268 [ OK ] NavigationControllerTest.Defaults (48 ms) |
| 258 [ RUN ] NavigationControllerTest.Reload | 269 [ RUN ] NavigationControllerTest.Reload |
| 259 %(reload_errors)s | 270 %(reload_errors)s |
| 260 [ FAILED ] NavigationControllerTest.Reload (2 ms) | 271 [ FAILED ] NavigationControllerTest.Reload (2 ms) |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 | 449 |
| 439 parser = gtest_utils.GTestLogParser() | 450 parser = gtest_utils.GTestLogParser() |
| 440 for line in FAILING_TESTS_OUTPUT.splitlines(): | 451 for line in FAILING_TESTS_OUTPUT.splitlines(): |
| 441 parser.ProcessLine(line) | 452 parser.ProcessLine(line) |
| 442 self.assertEqual(FAILING_TESTS_EXPECTED, | 453 self.assertEqual(FAILING_TESTS_EXPECTED, |
| 443 parser.FailedTests(True, True)) | 454 parser.FailedTests(True, True)) |
| 444 | 455 |
| 445 | 456 |
| 446 if __name__ == '__main__': | 457 if __name__ == '__main__': |
| 447 unittest.main() | 458 unittest.main() |
| OLD | NEW |