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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 '-c', 'Print:CFBundleIdentifier', | 171 '-c', 'Print:CFBundleIdentifier', |
| 172 os.path.join(app_path, 'Info.plist'), | 172 os.path.join(app_path, 'Info.plist'), |
| 173 ]).rstrip() | 173 ]).rstrip() |
| 174 self.env_vars = env_vars or [] | 174 self.env_vars = env_vars or [] |
| 175 self.logs = collections.OrderedDict() | 175 self.logs = collections.OrderedDict() |
| 176 self.out_dir = out_dir | 176 self.out_dir = out_dir |
| 177 self.test_args = test_args or [] | 177 self.test_args = test_args or [] |
| 178 self.xcode_version = xcode_version | 178 self.xcode_version = xcode_version |
| 179 self.xctest_path = '' | 179 self.xctest_path = '' |
| 180 | 180 |
| 181 self.test_results = collections.OrderedDict() | |
|
smut
2017/01/09 21:16:12
Does order matter?
rohitrao (ping after 24h)
2017/01/09 21:32:34
Nope. I was originally trying to match what summa
| |
| 182 self.test_results['version'] = 3 | |
| 183 self.test_results['path_delimiter'] = '.' | |
| 184 self.test_results['seconds_since_epoch'] = int(time.time()) | |
| 185 # This will be overwritten when the tests complete successfully. | |
| 186 self.test_results['interrupted'] = True | |
| 187 | |
| 181 if xctest: | 188 if xctest: |
| 182 plugins_dir = os.path.join(self.app_path, 'PlugIns') | 189 plugins_dir = os.path.join(self.app_path, 'PlugIns') |
| 183 if not os.path.exists(plugins_dir): | 190 if not os.path.exists(plugins_dir): |
| 184 raise PlugInsNotFoundError(plugins_dir) | 191 raise PlugInsNotFoundError(plugins_dir) |
| 185 for plugin in os.listdir(plugins_dir): | 192 for plugin in os.listdir(plugins_dir): |
| 186 if plugin.endswith('.xctest'): | 193 if plugin.endswith('.xctest'): |
| 187 self.xctest_path = os.path.join(plugins_dir, plugin) | 194 self.xctest_path = os.path.join(plugins_dir, plugin) |
| 188 if not os.path.exists(self.xctest_path): | 195 if not os.path.exists(self.xctest_path): |
| 189 raise XCTestPlugInNotFoundError(self.xctest_path) | 196 raise XCTestPlugInNotFoundError(self.xctest_path) |
| 190 | 197 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 313 passed.extend(result.passed_tests) | 320 passed.extend(result.passed_tests) |
| 314 failed.update(result.failed_tests) | 321 failed.update(result.failed_tests) |
| 315 flaked.update(result.flaked_tests) | 322 flaked.update(result.flaked_tests) |
| 316 except OSError as e: | 323 except OSError as e: |
| 317 if e.errno == errno.E2BIG: | 324 if e.errno == errno.E2BIG: |
| 318 print 'Too many test cases to resume.' | 325 print 'Too many test cases to resume.' |
| 319 print | 326 print |
| 320 else: | 327 else: |
| 321 raise | 328 raise |
| 322 | 329 |
| 330 # Build test_results.json | |
| 331 self.test_results['interrupted'] = result.crashed | |
| 332 self.test_results['num_failures_by_type'] = { | |
| 333 'FAIL': len(failed) + len(flaked), | |
| 334 'PASS': len(passed), | |
| 335 } | |
| 336 tests = collections.OrderedDict() | |
| 337 for test in passed: | |
| 338 tests[test] = { 'expected': 'PASS', 'actual': 'PASS' } | |
| 339 for test, _ in failed: | |
| 340 tests[test] = { 'expected': 'PASS', 'actual': 'FAIL' } | |
| 341 for test, _ in flaked: | |
| 342 tests[test] = { 'expected': 'PASS', 'actual': 'FAIL' } | |
| 343 self.test_results['tests'] = tests | |
| 344 | |
| 323 self.logs['passed tests'] = passed | 345 self.logs['passed tests'] = passed |
| 324 for test, log_lines in failed.iteritems(): | 346 for test, log_lines in failed.iteritems(): |
| 325 self.logs[test] = log_lines | 347 self.logs[test] = log_lines |
| 326 for test, log_lines in flaked.iteritems(): | 348 for test, log_lines in flaked.iteritems(): |
| 327 self.logs[test] = log_lines | 349 self.logs[test] = log_lines |
| 328 | 350 |
| 329 return not failed | 351 return not failed |
| 330 finally: | 352 finally: |
| 331 self.tear_down() | 353 self.tear_down() |
| 332 | 354 |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 679 """ | 701 """ |
| 680 env = super(DeviceTestRunner, self).get_launch_env() | 702 env = super(DeviceTestRunner, self).get_launch_env() |
| 681 if self.xctest_path: | 703 if self.xctest_path: |
| 682 env['NSUnbufferedIO'] = 'YES' | 704 env['NSUnbufferedIO'] = 'YES' |
| 683 # e.g. ios_web_shell_egtests | 705 # e.g. ios_web_shell_egtests |
| 684 env['APP_TARGET_NAME'] = os.path.splitext( | 706 env['APP_TARGET_NAME'] = os.path.splitext( |
| 685 os.path.basename(self.app_path))[0] | 707 os.path.basename(self.app_path))[0] |
| 686 # e.g. ios_web_shell_egtests_module | 708 # e.g. ios_web_shell_egtests_module |
| 687 env['TEST_TARGET_NAME'] = env['APP_TARGET_NAME'] + '_module' | 709 env['TEST_TARGET_NAME'] = env['APP_TARGET_NAME'] + '_module' |
| 688 return env | 710 return env |
| OLD | NEW |