| 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. |
| 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 |
| 300 proc.wait() | 311 proc.wait() |
| 301 sys.stdout.flush() | 312 sys.stdout.flush() |
| 302 | 313 |
| 303 for test in parser.FailedTests(include_flaky=True): | 314 for test in parser.FailedTests(include_flaky=True): |
| 304 # Test cases are named as <test group>.<test case>. If the test case | 315 # 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. | 316 # is prefixed with "FLAKY_", it should be reported as flaked not failed. |
| 306 if '.' in test and test.split('.', 1)[1].startswith('FLAKY_'): | 317 if '.' in test and test.split('.', 1)[1].startswith('FLAKY_'): |
| 307 result.flaked_tests[test] = parser.FailureDescription(test) | 318 result.flaked_tests[test] = parser.FailureDescription(test) |
| 308 else: | 319 else: |
| 309 result.failed_tests[test] = parser.FailureDescription(test) | 320 result.failed_tests[test] = parser.FailureDescription(test) |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 """ | 771 """ |
| 761 env = super(DeviceTestRunner, self).get_launch_env() | 772 env = super(DeviceTestRunner, self).get_launch_env() |
| 762 if self.xctest_path: | 773 if self.xctest_path: |
| 763 env['NSUnbufferedIO'] = 'YES' | 774 env['NSUnbufferedIO'] = 'YES' |
| 764 # e.g. ios_web_shell_egtests | 775 # e.g. ios_web_shell_egtests |
| 765 env['APP_TARGET_NAME'] = os.path.splitext( | 776 env['APP_TARGET_NAME'] = os.path.splitext( |
| 766 os.path.basename(self.app_path))[0] | 777 os.path.basename(self.app_path))[0] |
| 767 # e.g. ios_web_shell_egtests_module | 778 # e.g. ios_web_shell_egtests_module |
| 768 env['TEST_TARGET_NAME'] = env['APP_TARGET_NAME'] + '_module' | 779 env['TEST_TARGET_NAME'] = env['APP_TARGET_NAME'] + '_module' |
| 769 return env | 780 return env |
| OLD | NEW |