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