Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 """Test runners for iOS.""" | 5 """Test runners for iOS.""" |
| 6 | 6 |
| 7 import argparse | 7 import argparse |
| 8 import collections | 8 import collections |
| 9 import errno | 9 import errno |
| 10 import os | 10 import os |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 else: | 281 else: |
| 282 parser = gtest_utils.GTestLogParser() | 282 parser = gtest_utils.GTestLogParser() |
| 283 | 283 |
| 284 proc = subprocess.Popen( | 284 proc = subprocess.Popen( |
| 285 cmd, | 285 cmd, |
| 286 env=self.get_launch_env(), | 286 env=self.get_launch_env(), |
| 287 stdout=subprocess.PIPE, | 287 stdout=subprocess.PIPE, |
| 288 stderr=subprocess.STDOUT, | 288 stderr=subprocess.STDOUT, |
| 289 ) | 289 ) |
| 290 | 290 |
| 291 failure_count = 0 | |
| 291 while True: | 292 while True: |
| 292 line = proc.stdout.readline() | 293 line = proc.stdout.readline() |
| 293 if not line: | 294 if not line: |
| 294 break | 295 break |
| 295 line = line.rstrip() | 296 line = line.rstrip() |
| 296 parser.ProcessLine(line) | 297 parser.ProcessLine(line) |
| 297 print line | 298 print line |
| 298 sys.stdout.flush() | 299 sys.stdout.flush() |
| 299 | 300 |
| 301 # If there is a new test failure, take a desktop screenshot. | |
|
smut
2017/03/24 01:53:29
Could add a comment explaining that the parser con
| |
| 302 new_failure_count = len([test for test in parser.FailedTests() | |
| 303 if test != parser.GetCurrentTest()]) | |
| 304 if (new_failure_count > failure_count): | |
| 305 self.screenshot_desktop() | |
| 306 failure_count = new_failure_count | |
| 307 | |
| 300 proc.wait() | 308 proc.wait() |
| 301 sys.stdout.flush() | 309 sys.stdout.flush() |
| 302 | 310 |
| 303 for test in parser.FailedTests(include_flaky=True): | 311 for test in parser.FailedTests(include_flaky=True): |
| 304 # Test cases are named as <test group>.<test case>. If the test case | 312 # Test cases are named as <test group>.<test case>. If the test case |
| 305 # is prefixed with "FLAKY_", it should be reported as flaked not failed. | 313 # is prefixed with "FLAKY_", it should be reported as flaked not failed. |
| 306 if '.' in test and test.split('.', 1)[1].startswith('FLAKY_'): | 314 if '.' in test and test.split('.', 1)[1].startswith('FLAKY_'): |
| 307 result.flaked_tests[test] = parser.FailureDescription(test) | 315 result.flaked_tests[test] = parser.FailureDescription(test) |
| 308 else: | 316 else: |
| 309 result.failed_tests[test] = parser.FailureDescription(test) | 317 result.failed_tests[test] = parser.FailureDescription(test) |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 760 """ | 768 """ |
| 761 env = super(DeviceTestRunner, self).get_launch_env() | 769 env = super(DeviceTestRunner, self).get_launch_env() |
| 762 if self.xctest_path: | 770 if self.xctest_path: |
| 763 env['NSUnbufferedIO'] = 'YES' | 771 env['NSUnbufferedIO'] = 'YES' |
| 764 # e.g. ios_web_shell_egtests | 772 # e.g. ios_web_shell_egtests |
| 765 env['APP_TARGET_NAME'] = os.path.splitext( | 773 env['APP_TARGET_NAME'] = os.path.splitext( |
| 766 os.path.basename(self.app_path))[0] | 774 os.path.basename(self.app_path))[0] |
| 767 # e.g. ios_web_shell_egtests_module | 775 # e.g. ios_web_shell_egtests_module |
| 768 env['TEST_TARGET_NAME'] = env['APP_TARGET_NAME'] + '_module' | 776 env['TEST_TARGET_NAME'] = env['APP_TARGET_NAME'] + '_module' |
| 769 return env | 777 return env |
| OLD | NEW |