| 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 | |
| 292 while True: | 291 while True: |
| 293 line = proc.stdout.readline() | 292 line = proc.stdout.readline() |
| 294 if not line: | 293 if not line: |
| 295 break | 294 break |
| 296 line = line.rstrip() | 295 line = line.rstrip() |
| 297 parser.ProcessLine(line) | 296 parser.ProcessLine(line) |
| 298 print line | 297 print line |
| 299 sys.stdout.flush() | 298 sys.stdout.flush() |
| 300 | 299 |
| 301 # If there is a new test failure, take a desktop screenshot. | |
| 302 # parser.FailedTests() considers in progress tests as failed, so a check | |
| 303 # is needed that the current test isn't included in the list of failed | |
| 304 # tests. | |
| 305 new_failure_count = len([test for test in parser.FailedTests() | |
| 306 if test != parser.GetCurrentTest()]) | |
| 307 if (new_failure_count > failure_count): | |
| 308 self.screenshot_desktop() | |
| 309 failure_count = new_failure_count | |
| 310 | |
| 311 proc.wait() | 300 proc.wait() |
| 312 sys.stdout.flush() | 301 sys.stdout.flush() |
| 313 | 302 |
| 314 for test in parser.FailedTests(include_flaky=True): | 303 for test in parser.FailedTests(include_flaky=True): |
| 315 # Test cases are named as <test group>.<test case>. If the test case | 304 # Test cases are named as <test group>.<test case>. If the test case |
| 316 # is prefixed with "FLAKY_", it should be reported as flaked not failed. | 305 # is prefixed with "FLAKY_", it should be reported as flaked not failed. |
| 317 if '.' in test and test.split('.', 1)[1].startswith('FLAKY_'): | 306 if '.' in test and test.split('.', 1)[1].startswith('FLAKY_'): |
| 318 result.flaked_tests[test] = parser.FailureDescription(test) | 307 result.flaked_tests[test] = parser.FailureDescription(test) |
| 319 else: | 308 else: |
| 320 result.failed_tests[test] = parser.FailureDescription(test) | 309 result.failed_tests[test] = parser.FailureDescription(test) |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 """ | 760 """ |
| 772 env = super(DeviceTestRunner, self).get_launch_env() | 761 env = super(DeviceTestRunner, self).get_launch_env() |
| 773 if self.xctest_path: | 762 if self.xctest_path: |
| 774 env['NSUnbufferedIO'] = 'YES' | 763 env['NSUnbufferedIO'] = 'YES' |
| 775 # e.g. ios_web_shell_egtests | 764 # e.g. ios_web_shell_egtests |
| 776 env['APP_TARGET_NAME'] = os.path.splitext( | 765 env['APP_TARGET_NAME'] = os.path.splitext( |
| 777 os.path.basename(self.app_path))[0] | 766 os.path.basename(self.app_path))[0] |
| 778 # e.g. ios_web_shell_egtests_module | 767 # e.g. ios_web_shell_egtests_module |
| 779 env['TEST_TARGET_NAME'] = env['APP_TARGET_NAME'] + '_module' | 768 env['TEST_TARGET_NAME'] = env['APP_TARGET_NAME'] + '_module' |
| 780 return env | 769 return env |
| OLD | NEW |