Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import re | 5 import re |
| 6 import string | 6 import string |
| 7 | 7 |
| 8 | 8 |
| 9 class Test(object): | 9 class Test(object): |
| 10 """ | 10 """ |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 340 gtest_results = self._test_runs[suffix].test_utils.gtest_results | 340 gtest_results = self._test_runs[suffix].test_utils.gtest_results |
| 341 if not gtest_results.valid: # pragma: no cover | 341 if not gtest_results.valid: # pragma: no cover |
| 342 return False | 342 return False |
| 343 global_tags = gtest_results.raw.get('global_tags', []) | 343 global_tags = gtest_results.raw.get('global_tags', []) |
| 344 return 'UNRELIABLE_RESULTS' not in global_tags | 344 return 'UNRELIABLE_RESULTS' not in global_tags |
| 345 | 345 |
| 346 def failures(self, api, suffix): | 346 def failures(self, api, suffix): |
| 347 return self._test_runs[suffix].test_utils.gtest_results.failures | 347 return self._test_runs[suffix].test_utils.gtest_results.failures |
| 348 | 348 |
| 349 | 349 |
| 350 def generate_gtest(api, mastername, buildername, test_spec, | 350 def get_args_for_test(api, chromium_tests_api, test_spec, bot_update_step): |
| 351 enable_swarming=False, scripts_compile_targets=None): | 351 args = test_spec.get('args', []) |
| 352 if chromium_tests_api.is_precommit_mode(): | |
| 353 args = args + test_spec.get('precommit_args', []) | |
| 354 else: | |
| 355 args = args + test_spec.get('non_precommit_args', []) | |
| 356 # Perform substitution of known variables. | |
| 357 substitutions = { | |
| 358 'builder_name': api.properties.get('buildername'), | |
| 359 'master_name': api.properties.get('mastername'), | |
|
Sergey Berezin
2016/01/14 01:39:34
nit: IMHO, master name is an implementation detail
iannucci
2016/01/15 01:48:10
What sergey said is true...
That said, if we're
| |
| 360 'build_revision': bot_update_step.presentation.properties['got_revision'] | |
| 361 } | |
| 362 return [string.Template(arg).safe_substitute(substitutions) for arg in args] | |
| 363 | |
| 364 | |
| 365 def generate_gtest(api, chromium_tests_api, mastername, buildername, test_spec, | |
| 366 bot_update_step, enable_swarming=False, | |
| 367 scripts_compile_targets=None): | |
| 352 def canonicalize_test(test): | 368 def canonicalize_test(test): |
| 353 if isinstance(test, basestring): | 369 if isinstance(test, basestring): |
| 354 canonical_test = {'test': test} | 370 canonical_test = {'test': test} |
| 355 else: | 371 else: |
| 356 canonical_test = test.copy() | 372 canonical_test = test.copy() |
| 357 | 373 |
| 358 canonical_test.setdefault('shard_index', 0) | 374 canonical_test.setdefault('shard_index', 0) |
| 359 canonical_test.setdefault('total_shards', 1) | 375 canonical_test.setdefault('total_shards', 1) |
| 360 return canonical_test | 376 return canonical_test |
| 361 | 377 |
| 362 def get_tests(api): | 378 def get_tests(api): |
| 363 return [canonicalize_test(t) for t in | 379 return [canonicalize_test(t) for t in |
| 364 test_spec.get(buildername, {}).get('gtest_tests', [])] | 380 test_spec.get(buildername, {}).get('gtest_tests', [])] |
| 365 | 381 |
| 366 for test in get_tests(api): | 382 for test in get_tests(api): |
| 367 args = test.get('args', []) | 383 args = get_args_for_test(api, chromium_tests_api, test, bot_update_step) |
| 368 if test['shard_index'] != 0 or test['total_shards'] != 1: | 384 if test['shard_index'] != 0 or test['total_shards'] != 1: |
| 369 args.extend(['--test-launcher-shard-index=%d' % test['shard_index'], | 385 args.extend(['--test-launcher-shard-index=%d' % test['shard_index'], |
| 370 '--test-launcher-total-shards=%d' % test['total_shards']]) | 386 '--test-launcher-total-shards=%d' % test['total_shards']]) |
| 371 use_swarming = False | 387 use_swarming = False |
| 372 swarming_shards = 1 | 388 swarming_shards = 1 |
| 373 swarming_dimension_sets = None | 389 swarming_dimension_sets = None |
| 374 if enable_swarming: | 390 if enable_swarming: |
| 375 swarming_spec = test.get('swarming', {}) | 391 swarming_spec = test.get('swarming', {}) |
| 376 if swarming_spec.get('can_use_on_swarming_builders'): | 392 if swarming_spec.get('can_use_on_swarming_builders'): |
| 377 use_swarming = True | 393 use_swarming = True |
| 378 swarming_shards = swarming_spec.get('shards', 1) | 394 swarming_shards = swarming_spec.get('shards', 1) |
| 379 swarming_dimension_sets = swarming_spec.get('dimension_sets') | 395 swarming_dimension_sets = swarming_spec.get('dimension_sets') |
| 380 override_compile_targets = test.get('override_compile_targets', None) | 396 override_compile_targets = test.get('override_compile_targets', None) |
| 381 if use_swarming and swarming_dimension_sets: | 397 if use_swarming and swarming_dimension_sets: |
| 382 for dimensions in swarming_dimension_sets: | 398 for dimensions in swarming_dimension_sets: |
| 383 # Yield potentially multiple invocations of the same test, on | 399 # Yield potentially multiple invocations of the same test, on |
| 384 # different machine configurations. | 400 # different machine configurations. |
| 385 yield GTestTest(str(test['test']), args=args, flakiness_dash=True, | 401 yield GTestTest(str(test['test']), args=args, flakiness_dash=True, |
| 386 enable_swarming=True, | 402 enable_swarming=True, |
| 387 swarming_shards=swarming_shards, | 403 swarming_shards=swarming_shards, |
| 388 swarming_dimensions=dimensions, | 404 swarming_dimensions=dimensions, |
| 389 override_compile_targets=override_compile_targets) | 405 override_compile_targets=override_compile_targets) |
| 390 else: | 406 else: |
| 391 yield GTestTest(str(test['test']), args=args, flakiness_dash=True, | 407 yield GTestTest(str(test['test']), args=args, flakiness_dash=True, |
| 392 enable_swarming=use_swarming, | 408 enable_swarming=use_swarming, |
| 393 swarming_shards=swarming_shards, | 409 swarming_shards=swarming_shards, |
| 394 override_compile_targets=override_compile_targets) | 410 override_compile_targets=override_compile_targets) |
| 395 | 411 |
| 396 | 412 |
| 397 def generate_script(api, mastername, buildername, test_spec, | 413 def generate_script(api, chromium_tests_api, mastername, buildername, test_spec, |
| 398 enable_swarming=False, scripts_compile_targets=None): | 414 bot_update_step, enable_swarming=False, |
| 415 scripts_compile_targets=None): | |
| 399 for script_spec in test_spec.get(buildername, {}).get('scripts', []): | 416 for script_spec in test_spec.get(buildername, {}).get('scripts', []): |
| 400 yield ScriptTest( | 417 yield ScriptTest( |
| 401 str(script_spec['name']), | 418 str(script_spec['name']), |
| 402 script_spec['script'], | 419 script_spec['script'], |
| 403 scripts_compile_targets, # pragma: no cover | 420 scripts_compile_targets, # pragma: no cover |
| 404 script_spec.get('args', [])) | 421 get_args_for_test( |
| 422 api, chromium_tests_api, script_spec, bot_update_step)) | |
| 405 | 423 |
| 406 | 424 |
| 407 class DynamicPerfTests(Test): | 425 class DynamicPerfTests(Test): |
| 408 def __init__(self, perf_id, platform, target_bits, max_battery_temp=None, | 426 def __init__(self, perf_id, platform, target_bits, max_battery_temp=None, |
| 409 num_device_shards=1, num_host_shards=1, shard_index=0): | 427 num_device_shards=1, num_host_shards=1, shard_index=0): |
| 410 self._perf_id = perf_id | 428 self._perf_id = perf_id |
| 411 self._platform = platform | 429 self._platform = platform |
| 412 self._target_bits = target_bits | 430 self._target_bits = target_bits |
| 413 | 431 |
| 414 self._max_battery_temp = max_battery_temp | 432 self._max_battery_temp = max_battery_temp |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1109 step_result.presentation.logs['invalid_results_exc'] = [str(e)] | 1127 step_result.presentation.logs['invalid_results_exc'] = [str(e)] |
| 1110 valid = False | 1128 valid = False |
| 1111 failures = None | 1129 failures = None |
| 1112 if valid: | 1130 if valid: |
| 1113 step_result.presentation.step_text += api.test_utils.format_step_text([ | 1131 step_result.presentation.step_text += api.test_utils.format_step_text([ |
| 1114 ['failures:', failures] | 1132 ['failures:', failures] |
| 1115 ]) | 1133 ]) |
| 1116 return valid, failures | 1134 return valid, failures |
| 1117 | 1135 |
| 1118 | 1136 |
| 1119 def generate_isolated_script(api, mastername, buildername, test_spec, | 1137 def generate_isolated_script(api, chromium_tests_api, mastername, buildername, |
| 1120 enable_swarming=False, | 1138 test_spec, bot_update_step, enable_swarming=False, |
| 1121 scripts_compile_targets=None): | 1139 scripts_compile_targets=None): |
| 1122 for spec in test_spec.get(buildername, {}).get('isolated_scripts', []): | 1140 for spec in test_spec.get(buildername, {}).get('isolated_scripts', []): |
| 1123 use_swarming = False | 1141 use_swarming = False |
| 1124 swarming_shards = 1 | 1142 swarming_shards = 1 |
| 1125 swarming_dimension_sets = None | 1143 swarming_dimension_sets = None |
| 1126 if enable_swarming: | 1144 if enable_swarming: |
| 1127 swarming_spec = spec.get('swarming', {}) | 1145 swarming_spec = spec.get('swarming', {}) |
| 1128 if swarming_spec.get('can_use_on_swarming_builders', False): | 1146 if swarming_spec.get('can_use_on_swarming_builders', False): |
| 1129 use_swarming = True | 1147 use_swarming = True |
| 1130 swarming_shards = swarming_spec.get('shards', 1) | 1148 swarming_shards = swarming_spec.get('shards', 1) |
| 1131 swarming_dimension_sets = swarming_spec.get('dimension_sets') | 1149 swarming_dimension_sets = swarming_spec.get('dimension_sets') |
| 1132 name = str(spec['name']) | 1150 name = str(spec['name']) |
| 1133 args = args=spec.get('args', []) | 1151 args = get_args_for_test(api, chromium_tests_api, spec, bot_update_step) |
| 1134 target_name = spec['isolate_name'] | 1152 target_name = spec['isolate_name'] |
| 1135 # This features is only needed for the cases in which the *_run compile | 1153 # This features is only needed for the cases in which the *_run compile |
| 1136 # target is needed to generate isolate files that contains dynamically libs. | 1154 # target is needed to generate isolate files that contains dynamically libs. |
| 1137 # TODO(nednguyen, kbr): Remove this once all the GYP builds are converted | 1155 # TODO(nednguyen, kbr): Remove this once all the GYP builds are converted |
| 1138 # to GN. | 1156 # to GN. |
| 1139 override_compile_targets = spec.get('override_compile_targets', None) | 1157 override_compile_targets = spec.get('override_compile_targets', None) |
| 1140 if use_swarming: | 1158 if use_swarming: |
| 1141 if swarming_dimension_sets: | 1159 if swarming_dimension_sets: |
| 1142 for dimensions in swarming_dimension_sets: | 1160 for dimensions in swarming_dimension_sets: |
| 1143 # Yield potentially multiple invocations of the same test, | 1161 # Yield potentially multiple invocations of the same test, |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1711 def run(self, api, suffix, test_filter=None): | 1729 def run(self, api, suffix, test_filter=None): |
| 1712 api.chromium_android.coverage_report(upload=False) | 1730 api.chromium_android.coverage_report(upload=False) |
| 1713 api.chromium_android.get_changed_lines_for_revision() | 1731 api.chromium_android.get_changed_lines_for_revision() |
| 1714 api.chromium_android.incremental_coverage_report() | 1732 api.chromium_android.incremental_coverage_report() |
| 1715 | 1733 |
| 1716 | 1734 |
| 1717 GOMA_TESTS = [ | 1735 GOMA_TESTS = [ |
| 1718 GTestTest('base_unittests'), | 1736 GTestTest('base_unittests'), |
| 1719 GTestTest('content_unittests'), | 1737 GTestTest('content_unittests'), |
| 1720 ] | 1738 ] |
| OLD | NEW |