| 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 """Gets the argument list for a dynamically generated test, as |
| 352 provided by the JSON files in src/testing/buildbot/ in the Chromium |
| 353 workspace. This function provides the following build properties in |
| 354 the form of variable substitutions in the tests' argument lists: |
| 355 |
| 356 buildername |
| 357 got_revision |
| 358 |
| 359 so, for example, a test can declare the argument: |
| 360 |
| 361 --test-machine-name=\"${buildername}\" |
| 362 |
| 363 and ${buildername} will be replaced with the associated build |
| 364 property. In this example, it will also be double-quoted, to handle |
| 365 the case where the machine name contains contains spaces. |
| 366 |
| 367 This function also supports trybot-only and waterfall-only |
| 368 arguments, so that a test can pass a different argument lists on the |
| 369 continuous builders compared to tryjobs. This is useful when the |
| 370 waterfall bots generate some reference data that is tested against |
| 371 during tryjobs. |
| 372 """ |
| 373 |
| 374 args = test_spec.get('args', []) |
| 375 if chromium_tests_api.is_precommit_mode(): |
| 376 args = args + test_spec.get('precommit_args', []) |
| 377 else: |
| 378 args = args + test_spec.get('non_precommit_args', []) |
| 379 # Perform substitution of known variables. |
| 380 substitutions = { |
| 381 'buildername': api.properties.get('buildername'), |
| 382 'got_revision': bot_update_step.presentation.properties['got_revision'] |
| 383 } |
| 384 return [string.Template(arg).safe_substitute(substitutions) for arg in args] |
| 385 |
| 386 |
| 387 def generate_gtest(api, chromium_tests_api, mastername, buildername, test_spec, |
| 388 bot_update_step, enable_swarming=False, |
| 389 scripts_compile_targets=None): |
| 352 def canonicalize_test(test): | 390 def canonicalize_test(test): |
| 353 if isinstance(test, basestring): | 391 if isinstance(test, basestring): |
| 354 canonical_test = {'test': test} | 392 canonical_test = {'test': test} |
| 355 else: | 393 else: |
| 356 canonical_test = test.copy() | 394 canonical_test = test.copy() |
| 357 | 395 |
| 358 canonical_test.setdefault('shard_index', 0) | 396 canonical_test.setdefault('shard_index', 0) |
| 359 canonical_test.setdefault('total_shards', 1) | 397 canonical_test.setdefault('total_shards', 1) |
| 360 return canonical_test | 398 return canonical_test |
| 361 | 399 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 391 swarming_dimensions=dimensions, | 429 swarming_dimensions=dimensions, |
| 392 override_compile_targets=override_compile_targets) | 430 override_compile_targets=override_compile_targets) |
| 393 else: | 431 else: |
| 394 yield GTestTest(name, args=args, target_name=target_name, | 432 yield GTestTest(name, args=args, target_name=target_name, |
| 395 flakiness_dash=True, | 433 flakiness_dash=True, |
| 396 enable_swarming=use_swarming, | 434 enable_swarming=use_swarming, |
| 397 swarming_shards=swarming_shards, | 435 swarming_shards=swarming_shards, |
| 398 override_compile_targets=override_compile_targets) | 436 override_compile_targets=override_compile_targets) |
| 399 | 437 |
| 400 | 438 |
| 401 def generate_script(api, mastername, buildername, test_spec, | 439 def generate_script(api, chromium_tests_api, mastername, buildername, test_spec, |
| 402 enable_swarming=False, scripts_compile_targets=None): | 440 bot_update_step, enable_swarming=False, |
| 441 scripts_compile_targets=None): |
| 403 for script_spec in test_spec.get(buildername, {}).get('scripts', []): | 442 for script_spec in test_spec.get(buildername, {}).get('scripts', []): |
| 404 yield ScriptTest( | 443 yield ScriptTest( |
| 405 str(script_spec['name']), | 444 str(script_spec['name']), |
| 406 script_spec['script'], | 445 script_spec['script'], |
| 407 scripts_compile_targets, # pragma: no cover | 446 scripts_compile_targets, # pragma: no cover |
| 408 script_spec.get('args', [])) | 447 script_spec.get('args', [])) |
| 409 | 448 |
| 410 | 449 |
| 411 class DynamicPerfTests(Test): | 450 class DynamicPerfTests(Test): |
| 412 def __init__(self, perf_id, platform, target_bits, max_battery_temp=None, | 451 def __init__(self, perf_id, platform, target_bits, max_battery_temp=None, |
| (...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 step_result.presentation.logs['invalid_results_exc'] = [str(e)] | 1152 step_result.presentation.logs['invalid_results_exc'] = [str(e)] |
| 1114 valid = False | 1153 valid = False |
| 1115 failures = None | 1154 failures = None |
| 1116 if valid: | 1155 if valid: |
| 1117 step_result.presentation.step_text += api.test_utils.format_step_text([ | 1156 step_result.presentation.step_text += api.test_utils.format_step_text([ |
| 1118 ['failures:', failures] | 1157 ['failures:', failures] |
| 1119 ]) | 1158 ]) |
| 1120 return valid, failures | 1159 return valid, failures |
| 1121 | 1160 |
| 1122 | 1161 |
| 1123 def generate_isolated_script(api, mastername, buildername, test_spec, | 1162 def generate_isolated_script(api, chromium_tests_api, mastername, buildername, |
| 1124 enable_swarming=False, | 1163 test_spec, bot_update_step, enable_swarming=False, |
| 1125 scripts_compile_targets=None): | 1164 scripts_compile_targets=None): |
| 1126 for spec in test_spec.get(buildername, {}).get('isolated_scripts', []): | 1165 for spec in test_spec.get(buildername, {}).get('isolated_scripts', []): |
| 1127 use_swarming = False | 1166 use_swarming = False |
| 1128 swarming_shards = 1 | 1167 swarming_shards = 1 |
| 1129 swarming_dimension_sets = None | 1168 swarming_dimension_sets = None |
| 1130 if enable_swarming: | 1169 if enable_swarming: |
| 1131 swarming_spec = spec.get('swarming', {}) | 1170 swarming_spec = spec.get('swarming', {}) |
| 1132 if swarming_spec.get('can_use_on_swarming_builders', False): | 1171 if swarming_spec.get('can_use_on_swarming_builders', False): |
| 1133 use_swarming = True | 1172 use_swarming = True |
| 1134 swarming_shards = swarming_spec.get('shards', 1) | 1173 swarming_shards = swarming_spec.get('shards', 1) |
| 1135 swarming_dimension_sets = swarming_spec.get('dimension_sets') | 1174 swarming_dimension_sets = swarming_spec.get('dimension_sets') |
| 1136 name = str(spec['name']) | 1175 name = str(spec['name']) |
| 1137 args = args=spec.get('args', []) | 1176 # The variable substitution and precommit/non-precommit arguments |
| 1177 # could be supported for the other test types too, but that wasn't |
| 1178 # desired at the time of this writing. |
| 1179 args = get_args_for_test(api, chromium_tests_api, spec, bot_update_step) |
| 1138 target_name = spec['isolate_name'] | 1180 target_name = spec['isolate_name'] |
| 1139 # This features is only needed for the cases in which the *_run compile | 1181 # This features is only needed for the cases in which the *_run compile |
| 1140 # target is needed to generate isolate files that contains dynamically libs. | 1182 # target is needed to generate isolate files that contains dynamically libs. |
| 1141 # TODO(nednguyen, kbr): Remove this once all the GYP builds are converted | 1183 # TODO(nednguyen, kbr): Remove this once all the GYP builds are converted |
| 1142 # to GN. | 1184 # to GN. |
| 1143 override_compile_targets = spec.get('override_compile_targets', None) | 1185 override_compile_targets = spec.get('override_compile_targets', None) |
| 1144 if use_swarming: | 1186 if use_swarming: |
| 1145 if swarming_dimension_sets: | 1187 if swarming_dimension_sets: |
| 1146 for dimensions in swarming_dimension_sets: | 1188 for dimensions in swarming_dimension_sets: |
| 1147 # Yield potentially multiple invocations of the same test, | 1189 # Yield potentially multiple invocations of the same test, |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1719 def run(self, api, suffix, test_filter=None): | 1761 def run(self, api, suffix, test_filter=None): |
| 1720 api.chromium_android.coverage_report(upload=False) | 1762 api.chromium_android.coverage_report(upload=False) |
| 1721 api.chromium_android.get_changed_lines_for_revision() | 1763 api.chromium_android.get_changed_lines_for_revision() |
| 1722 api.chromium_android.incremental_coverage_report() | 1764 api.chromium_android.incremental_coverage_report() |
| 1723 | 1765 |
| 1724 | 1766 |
| 1725 GOMA_TESTS = [ | 1767 GOMA_TESTS = [ |
| 1726 GTestTest('base_unittests'), | 1768 GTestTest('base_unittests'), |
| 1727 GTestTest('content_unittests'), | 1769 GTestTest('content_unittests'), |
| 1728 ] | 1770 ] |
| OLD | NEW |