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 substitutions = {'name': self._name} |
| 121 |
| 122 return [string.Template(s).safe_substitute(substitutions) |
| 123 for s in self._all_compile_targets[self._script]] |
119 except KeyError: | 124 except KeyError: |
120 # Not all scripts will have test data inside recipes, | 125 # Not all scripts will have test data inside recipes, |
121 # so return a default value. | 126 # so return a default value. |
122 # TODO(phajdan.jr): Revisit this when all script tests | 127 # TODO(phajdan.jr): Revisit this when all script tests |
123 # lists move src-side. We should be able to provide | 128 # lists move src-side. We should be able to provide |
124 # test data then. | 129 # test data then. |
125 if api.chromium._test_data.enabled: | 130 if api.chromium._test_data.enabled: |
126 return [] | 131 return [] |
127 | 132 |
128 raise # pragma: no cover | 133 raise # pragma: no cover |
129 | 134 |
130 def run(self, api, suffix): | 135 def run(self, api, suffix): |
131 name = self.name | 136 name = self.name |
132 if suffix: | 137 if suffix: |
133 name += ' (%s)' % suffix | 138 name += ' (%s)' % suffix |
134 | 139 |
135 run_args = [] | 140 run_args = [] |
136 if suffix == 'without patch': | 141 if suffix == 'without patch': |
137 run_args.extend([ | 142 run_args.extend([ |
138 '--filter-file', api.json.input(self.failures(api, 'with patch')) | 143 '--filter-file', api.json.input(self.failures(api, 'with patch')) |
139 ]) # pragma: no cover | 144 ]) # pragma: no cover |
140 | 145 |
141 try: | 146 try: |
| 147 script_args = [] |
| 148 if self._script_args: |
| 149 script_args = ['--args', api.json.input(self._script_args)] |
142 api.python( | 150 api.python( |
143 name, | 151 name, |
144 # Enforce that all scripts are in the specified directory | 152 # Enforce that all scripts are in the specified directory |
145 # for consistency. | 153 # for consistency. |
146 api.path['checkout'].join( | 154 api.path['checkout'].join( |
147 'testing', 'scripts', api.path.basename(self._script)), | 155 'testing', 'scripts', api.path.basename(self._script)), |
148 args=(api.chromium.get_common_args_for_scripts() + | 156 args=(api.chromium.get_common_args_for_scripts() + |
| 157 script_args + |
149 ['run', '--output', api.json.output()] + | 158 ['run', '--output', api.json.output()] + |
150 run_args), | 159 run_args), |
151 step_test_data=lambda: api.json.test_api.output( | 160 step_test_data=lambda: api.json.test_api.output( |
152 {'valid': True, 'failures': []})) | 161 {'valid': True, 'failures': []})) |
153 finally: | 162 finally: |
154 self._test_runs[suffix] = api.step.active_result | 163 self._test_runs[suffix] = api.step.active_result |
155 | 164 |
156 return self._test_runs[suffix] | 165 return self._test_runs[suffix] |
157 | 166 |
158 def has_valid_results(self, api, suffix): | 167 def has_valid_results(self, api, suffix): |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 enable_swarming=use_swarming, | 340 enable_swarming=use_swarming, |
332 swarming_shards=swarming_shards) | 341 swarming_shards=swarming_shards) |
333 | 342 |
334 | 343 |
335 def generate_script(api, mastername, buildername, test_spec, | 344 def generate_script(api, mastername, buildername, test_spec, |
336 enable_swarming=False, scripts_compile_targets=None): | 345 enable_swarming=False, scripts_compile_targets=None): |
337 for script_spec in test_spec.get(buildername, {}).get('scripts', []): | 346 for script_spec in test_spec.get(buildername, {}).get('scripts', []): |
338 yield ScriptTest( | 347 yield ScriptTest( |
339 str(script_spec['name']), | 348 str(script_spec['name']), |
340 script_spec['script'], | 349 script_spec['script'], |
341 scripts_compile_targets) # pragma: no cover | 350 scripts_compile_targets, # pragma: no cover |
| 351 script_spec.get('args', [])) |
342 | 352 |
343 | 353 |
344 class DynamicPerfTests(Test): | 354 class DynamicPerfTests(Test): |
345 def __init__(self, browser, perf_id, shard_index, num_shards): | 355 def __init__(self, browser, perf_id, shard_index, num_shards): |
346 self.browser = browser | 356 self.browser = browser |
347 self.perf_id = perf_id | 357 self.perf_id = perf_id |
348 self.shard_index = shard_index | 358 self.shard_index = shard_index |
349 self.num_shards = num_shards | 359 self.num_shards = num_shards |
350 | 360 |
351 @property | 361 @property |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 GTestTest('crypto_unittests'), | 1169 GTestTest('crypto_unittests'), |
1160 GTestTest('gfx_unittests'), | 1170 GTestTest('gfx_unittests'), |
1161 GTestTest('url_unittests'), | 1171 GTestTest('url_unittests'), |
1162 GTestTest('content_unittests'), | 1172 GTestTest('content_unittests'), |
1163 GTestTest('net_unittests'), | 1173 GTestTest('net_unittests'), |
1164 GTestTest('ui_base_unittests'), | 1174 GTestTest('ui_base_unittests'), |
1165 GTestTest('ui_ios_unittests'), | 1175 GTestTest('ui_ios_unittests'), |
1166 GTestTest('sync_unit_tests'), | 1176 GTestTest('sync_unit_tests'), |
1167 GTestTest('sql_unittests'), | 1177 GTestTest('sql_unittests'), |
1168 ] | 1178 ] |
OLD | NEW |