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 | 7 |
| 7 | 8 |
| 8 class Test(object): | 9 class Test(object): |
| 9 """ | 10 """ |
| 10 Base class for tests that can be retried after deapplying a previously | 11 Base class for tests that can be retried after deapplying a previously |
| 11 applied patch. | 12 applied patch. |
| 12 """ | 13 """ |
| 13 | 14 |
| 14 def __init__(self): | 15 def __init__(self): |
| 15 super(Test, self).__init__() | 16 super(Test, self).__init__() |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 | 97 |
| 97 This makes it possible to keep the logic src-side as opposed | 98 This makes it possible to keep the logic src-side as opposed |
| 98 to the build repo most Chromium developers are unfamiliar with. | 99 to the build repo most Chromium developers are unfamiliar with. |
| 99 | 100 |
| 100 Another advantage is being to test changes to these scripts | 101 Another advantage is being to test changes to these scripts |
| 101 on trybots. | 102 on trybots. |
| 102 | 103 |
| 103 All new tests are strongly encouraged to use this infrastructure. | 104 All new tests are strongly encouraged to use this infrastructure. |
| 104 """ | 105 """ |
| 105 | 106 |
| 106 def __init__(self, name, script, all_compile_targets): | 107 def __init__(self, name, script, all_compile_targets, script_args=None): |
| 107 super(ScriptTest, self).__init__() | 108 super(ScriptTest, self).__init__() |
| 108 self._name = name | 109 self._name = name |
| 109 self._script = script | 110 self._script = script |
| 110 self._all_compile_targets = all_compile_targets | 111 self._all_compile_targets = all_compile_targets |
| 112 self._script_args = script_args | |
| 111 | 113 |
| 112 @property | 114 @property |
| 113 def name(self): | 115 def name(self): |
| 114 return self._name | 116 return self._name |
| 115 | 117 |
| 116 def compile_targets(self, api): | 118 def compile_targets(self, api): |
| 117 try: | 119 try: |
| 118 return self._all_compile_targets[self._script] | 120 substitions = {} |
| 121 if self._script_args: | |
| 122 substitions = {'name': self._script_args[0]} | |
|
Paweł Hajdan Jr.
2015/02/23 20:44:18
This is confusing - why is this conditional on sel
shatch
2015/02/23 21:05:55
Added a conditional since not every script passes
| |
| 123 | |
| 124 return [string.Template(s).safe_substitute(substitions) | |
| 125 for s in self._all_compile_targets[self._script]] | |
| 119 except KeyError: | 126 except KeyError: |
| 120 # Not all scripts will have test data inside recipes, | 127 # Not all scripts will have test data inside recipes, |
| 121 # so return a default value. | 128 # so return a default value. |
| 122 # TODO(phajdan.jr): Revisit this when all script tests | 129 # TODO(phajdan.jr): Revisit this when all script tests |
| 123 # lists move src-side. We should be able to provide | 130 # lists move src-side. We should be able to provide |
| 124 # test data then. | 131 # test data then. |
| 125 if api.chromium._test_data.enabled: | 132 if api.chromium._test_data.enabled: |
| 126 return [] | 133 return [] |
| 127 | 134 |
| 128 raise | 135 raise |
| 129 | 136 |
| 130 def run(self, api, suffix): | 137 def run(self, api, suffix): |
| 131 name = self.name | 138 name = self.name |
| 132 if suffix: | 139 if suffix: |
| 133 name += ' (%s)' % suffix | 140 name += ' (%s)' % suffix |
| 134 | 141 |
| 135 run_args = [] | 142 run_args = [] |
| 136 if suffix == 'without patch': | 143 if suffix == 'without patch': |
| 137 run_args.extend([ | 144 run_args.extend([ |
| 138 '--filter-file', api.json.input(self.failures(api, 'with patch')) | 145 '--filter-file', api.json.input(self.failures(api, 'with patch')) |
| 139 ]) | 146 ]) |
| 140 | 147 |
| 141 try: | 148 try: |
| 149 script_args = [] | |
| 150 if self._script_args: | |
| 151 script_args = ['--args', api.json.input(self._script_args)] | |
| 142 api.python( | 152 api.python( |
| 143 name, | 153 name, |
| 144 # Enforce that all scripts are in the specified directory | 154 # Enforce that all scripts are in the specified directory |
| 145 # for consistency. | 155 # for consistency. |
| 146 api.path['checkout'].join( | 156 api.path['checkout'].join( |
| 147 'testing', 'scripts', api.path.basename(self._script)), | 157 'testing', 'scripts', api.path.basename(self._script)), |
| 148 args=(api.chromium.get_common_args_for_scripts() + | 158 args=(api.chromium.get_common_args_for_scripts() + |
| 159 script_args + | |
| 149 ['run', '--output', api.json.output()] + | 160 ['run', '--output', api.json.output()] + |
| 150 run_args), | 161 run_args), |
| 151 step_test_data=lambda: api.json.test_api.output( | 162 step_test_data=lambda: api.json.test_api.output( |
| 152 {'valid': True, 'failures': []})) | 163 {'valid': True, 'failures': []})) |
| 153 finally: | 164 finally: |
| 154 self._test_runs[suffix] = api.step.active_result | 165 self._test_runs[suffix] = api.step.active_result |
| 155 | 166 |
| 156 return self._test_runs[suffix] | 167 return self._test_runs[suffix] |
| 157 | 168 |
| 158 def has_valid_results(self, api, suffix): | 169 def has_valid_results(self, api, suffix): |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 enable_swarming=use_swarming, | 328 enable_swarming=use_swarming, |
| 318 swarming_shards=swarming_shards) | 329 swarming_shards=swarming_shards) |
| 319 | 330 |
| 320 | 331 |
| 321 def generate_script(api, mastername, buildername, test_spec, | 332 def generate_script(api, mastername, buildername, test_spec, |
| 322 enable_swarming=False, scripts_compile_targets=None): | 333 enable_swarming=False, scripts_compile_targets=None): |
| 323 for script_spec in test_spec.get(buildername, {}).get('scripts', []): | 334 for script_spec in test_spec.get(buildername, {}).get('scripts', []): |
| 324 yield ScriptTest( | 335 yield ScriptTest( |
| 325 str(script_spec['name']), | 336 str(script_spec['name']), |
| 326 script_spec['script'], | 337 script_spec['script'], |
| 327 scripts_compile_targets) | 338 scripts_compile_targets, |
| 339 script_spec.get('args', [])) | |
| 328 | 340 |
| 329 | 341 |
| 330 class DynamicPerfTests(Test): | 342 class DynamicPerfTests(Test): |
| 331 def __init__(self, browser, perf_id, shard_index, num_shards): | 343 def __init__(self, browser, perf_id, shard_index, num_shards): |
| 332 self.browser = browser | 344 self.browser = browser |
| 333 self.perf_id = perf_id | 345 self.perf_id = perf_id |
| 334 self.shard_index = shard_index | 346 self.shard_index = shard_index |
| 335 self.num_shards = num_shards | 347 self.num_shards = num_shards |
| 336 | 348 |
| 337 @property | 349 @property |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1039 GTestTest('crypto_unittests'), | 1051 GTestTest('crypto_unittests'), |
| 1040 GTestTest('gfx_unittests'), | 1052 GTestTest('gfx_unittests'), |
| 1041 GTestTest('url_unittests'), | 1053 GTestTest('url_unittests'), |
| 1042 GTestTest('content_unittests'), | 1054 GTestTest('content_unittests'), |
| 1043 GTestTest('net_unittests'), | 1055 GTestTest('net_unittests'), |
| 1044 GTestTest('ui_base_unittests'), | 1056 GTestTest('ui_base_unittests'), |
| 1045 GTestTest('ui_ios_unittests'), | 1057 GTestTest('ui_ios_unittests'), |
| 1046 GTestTest('sync_unit_tests'), | 1058 GTestTest('sync_unit_tests'), |
| 1047 GTestTest('sql_unittests'), | 1059 GTestTest('sql_unittests'), |
| 1048 ] | 1060 ] |
| OLD | NEW |