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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 '-c', 'Print:CFBundleIdentifier', | 180 '-c', 'Print:CFBundleIdentifier', |
| 181 os.path.join(app_path, 'Info.plist'), | 181 os.path.join(app_path, 'Info.plist'), |
| 182 ]).rstrip() | 182 ]).rstrip() |
| 183 self.env_vars = env_vars or [] | 183 self.env_vars = env_vars or [] |
| 184 self.logs = collections.OrderedDict() | 184 self.logs = collections.OrderedDict() |
| 185 self.out_dir = out_dir | 185 self.out_dir = out_dir |
| 186 self.test_args = test_args or [] | 186 self.test_args = test_args or [] |
| 187 self.xcode_version = xcode_version | 187 self.xcode_version = xcode_version |
| 188 self.xctest_path = '' | 188 self.xctest_path = '' |
| 189 | 189 |
| 190 self.test_results = {} | |
| 191 self.test_results['version'] = 3 | |
| 192 self.test_results['path_delimiter'] = '.' | |
| 193 self.test_results['seconds_since_epoch'] = int(time.time()) | |
| 194 # This will be overwritten when the tests complete successfully. | |
| 195 self.test_results['interrupted'] = True | |
| 196 | |
| 190 if xctest: | 197 if xctest: |
| 191 plugins_dir = os.path.join(self.app_path, 'PlugIns') | 198 plugins_dir = os.path.join(self.app_path, 'PlugIns') |
| 192 if not os.path.exists(plugins_dir): | 199 if not os.path.exists(plugins_dir): |
| 193 raise PlugInsNotFoundError(plugins_dir) | 200 raise PlugInsNotFoundError(plugins_dir) |
| 194 for plugin in os.listdir(plugins_dir): | 201 for plugin in os.listdir(plugins_dir): |
| 195 if plugin.endswith('.xctest'): | 202 if plugin.endswith('.xctest'): |
| 196 self.xctest_path = os.path.join(plugins_dir, plugin) | 203 self.xctest_path = os.path.join(plugins_dir, plugin) |
| 197 if not os.path.exists(self.xctest_path): | 204 if not os.path.exists(self.xctest_path): |
| 198 raise XCTestPlugInNotFoundError(self.xctest_path) | 205 raise XCTestPlugInNotFoundError(self.xctest_path) |
| 199 | 206 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 342 passed.extend(result.passed_tests) | 349 passed.extend(result.passed_tests) |
| 343 failed.update(result.failed_tests) | 350 failed.update(result.failed_tests) |
| 344 flaked.update(result.flaked_tests) | 351 flaked.update(result.flaked_tests) |
| 345 except OSError as e: | 352 except OSError as e: |
| 346 if e.errno == errno.E2BIG: | 353 if e.errno == errno.E2BIG: |
| 347 print 'Too many test cases to resume.' | 354 print 'Too many test cases to resume.' |
| 348 print | 355 print |
| 349 else: | 356 else: |
| 350 raise | 357 raise |
| 351 | 358 |
| 359 # Build test_results.json | |
|
lpromero
2017/01/10 14:34:04
Add a period.
rohitrao (ping after 24h)
2017/01/10 17:39:31
Done.
| |
| 360 self.test_results['interrupted'] = result.crashed | |
| 361 self.test_results['num_failures_by_type'] = { | |
| 362 'FAIL': len(failed) + len(flaked), | |
| 363 'PASS': len(passed), | |
| 364 } | |
|
lpromero
2017/01/10 14:34:04
Is this indent correct?
rohitrao (ping after 24h)
2017/01/10 17:39:31
Not sure, moved it out two.
| |
| 365 tests = collections.OrderedDict() | |
| 366 for test in passed: | |
| 367 tests[test] = { 'expected': 'PASS', 'actual': 'PASS' } | |
| 368 for test, _ in failed: | |
| 369 tests[test] = { 'expected': 'PASS', 'actual': 'FAIL' } | |
| 370 for test, _ in flaked: | |
| 371 tests[test] = { 'expected': 'PASS', 'actual': 'FAIL' } | |
| 372 self.test_results['tests'] = tests | |
| 373 | |
| 352 self.logs['passed tests'] = passed | 374 self.logs['passed tests'] = passed |
| 353 for test, log_lines in failed.iteritems(): | 375 for test, log_lines in failed.iteritems(): |
| 354 self.logs[test] = log_lines | 376 self.logs[test] = log_lines |
| 355 for test, log_lines in flaked.iteritems(): | 377 for test, log_lines in flaked.iteritems(): |
| 356 self.logs[test] = log_lines | 378 self.logs[test] = log_lines |
| 357 | 379 |
| 358 return not failed | 380 return not failed |
| 359 finally: | 381 finally: |
| 360 self.tear_down() | 382 self.tear_down() |
| 361 | 383 |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 718 """ | 740 """ |
| 719 env = super(DeviceTestRunner, self).get_launch_env() | 741 env = super(DeviceTestRunner, self).get_launch_env() |
| 720 if self.xctest_path: | 742 if self.xctest_path: |
| 721 env['NSUnbufferedIO'] = 'YES' | 743 env['NSUnbufferedIO'] = 'YES' |
| 722 # e.g. ios_web_shell_egtests | 744 # e.g. ios_web_shell_egtests |
| 723 env['APP_TARGET_NAME'] = os.path.splitext( | 745 env['APP_TARGET_NAME'] = os.path.splitext( |
| 724 os.path.basename(self.app_path))[0] | 746 os.path.basename(self.app_path))[0] |
| 725 # e.g. ios_web_shell_egtests_module | 747 # e.g. ios_web_shell_egtests_module |
| 726 env['TEST_TARGET_NAME'] = env['APP_TARGET_NAME'] + '_module' | 748 env['TEST_TARGET_NAME'] = env['APP_TARGET_NAME'] + '_module' |
| 727 return env | 749 return env |
| OLD | NEW |