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 HTMLParser | 5 import HTMLParser |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 import re | 8 import re |
9 import tempfile | 9 import tempfile |
10 import xml.etree.ElementTree | 10 import xml.etree.ElementTree |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 | 191 |
192 results.append(base_test_result.BaseTestResult( | 192 results.append(base_test_result.BaseTestResult( |
193 '%s.%s' % (suite_name, case_name), | 193 '%s.%s' % (suite_name, case_name), |
194 result_type, | 194 result_type, |
195 int(float(testcase.attrib['time']) * 1000), | 195 int(float(testcase.attrib['time']) * 1000), |
196 log=('\n'.join(log) if log else ''))) | 196 log=('\n'.join(log) if log else ''))) |
197 | 197 |
198 return results | 198 return results |
199 | 199 |
200 | 200 |
201 # Converts file contents described by //testing/buildbot/filters/README.md | |
jbudorick
2016/11/03 18:21:18
Nit: make this a docstring, please.
Łukasz Anforowicz
2016/11/03 19:34:38
Ooops. Thanks for catching this. I guess I've be
| |
202 # into an argument for --gtest_filter command line parameter. | |
203 def ConvertTestFilterFileIntoGTestFilterArgument(input_lines): | |
204 # Strip whitespace + skip empty lines and lines beginning with '#'. | |
205 stripped_lines = (l.strip() for l in input_lines) | |
206 filter_lines = list(l for l in stripped_lines if l and l[0] != '#') | |
207 | |
208 # Split the tests into positive and negative patterns (gtest treats | |
209 # every pattern after the first '-' sign as an exclusion). | |
210 positive_patterns = ':'.join(l for l in filter_lines if l[0] != '-') | |
211 negative_patterns = ':'.join(l[1:] for l in filter_lines if l[0] == '-') | |
212 if negative_patterns: | |
213 negative_patterns = '-' + negative_patterns | |
214 | |
215 # Join the filter lines into one, big --gtest_filter argument. | |
216 return positive_patterns + negative_patterns | |
217 | |
218 | |
201 class GtestTestInstance(test_instance.TestInstance): | 219 class GtestTestInstance(test_instance.TestInstance): |
202 | 220 |
203 def __init__(self, args, isolate_delegate, error_func): | 221 def __init__(self, args, isolate_delegate, error_func): |
204 super(GtestTestInstance, self).__init__() | 222 super(GtestTestInstance, self).__init__() |
205 # TODO(jbudorick): Support multiple test suites. | 223 # TODO(jbudorick): Support multiple test suites. |
206 if len(args.suite_name) > 1: | 224 if len(args.suite_name) > 1: |
207 raise ValueError('Platform mode currently supports only 1 gtest suite') | 225 raise ValueError('Platform mode currently supports only 1 gtest suite') |
208 self._extract_test_list_from_filter = args.extract_test_list_from_filter | 226 self._extract_test_list_from_filter = args.extract_test_list_from_filter |
209 self._shard_timeout = args.shard_timeout | 227 self._shard_timeout = args.shard_timeout |
210 self._suite = args.suite_name[0] | 228 self._suite = args.suite_name[0] |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
245 self._shard_timeout = 10 * self._shard_timeout | 263 self._shard_timeout = 10 * self._shard_timeout |
246 | 264 |
247 if not self._apk_helper and not self._exe_dist_dir: | 265 if not self._apk_helper and not self._exe_dist_dir: |
248 error_func('Could not find apk or executable for %s' % self._suite) | 266 error_func('Could not find apk or executable for %s' % self._suite) |
249 | 267 |
250 self._data_deps = [] | 268 self._data_deps = [] |
251 if args.test_filter: | 269 if args.test_filter: |
252 self._gtest_filter = args.test_filter | 270 self._gtest_filter = args.test_filter |
253 elif args.test_filter_file: | 271 elif args.test_filter_file: |
254 with open(args.test_filter_file, 'r') as f: | 272 with open(args.test_filter_file, 'r') as f: |
255 # Strip whitespace + skip empty lines and lines beginning with '#'. | 273 self._gtest_filter = ConvertTestFilterFileIntoGTestFilterArgument(f) |
256 # This should be consistent with processing of | |
257 # --test-launcher-filter-file in base/test/launcher/test_launcher.cc. | |
258 stripped_lines = (l.strip() for l in f) | |
259 filter_lines = (l for l in stripped_lines if l and l[0] != '#') | |
260 # Join the filter lines into one, big --gtest_filter argument. | |
261 self._gtest_filter = ':'.join(filter_lines) | |
262 else: | 274 else: |
263 self._gtest_filter = None | 275 self._gtest_filter = None |
264 | 276 |
265 if (args.isolate_file_path and | 277 if (args.isolate_file_path and |
266 not isolator.IsIsolateEmpty(args.isolate_file_path)): | 278 not isolator.IsIsolateEmpty(args.isolate_file_path)): |
267 self._isolate_abs_path = os.path.abspath(args.isolate_file_path) | 279 self._isolate_abs_path = os.path.abspath(args.isolate_file_path) |
268 self._isolate_delegate = isolate_delegate | 280 self._isolate_delegate = isolate_delegate |
269 self._isolated_abs_path = os.path.join( | 281 self._isolated_abs_path = os.path.join( |
270 constants.GetOutDirectory(), '%s.isolated' % self._suite) | 282 constants.GetOutDirectory(), '%s.isolated' % self._suite) |
271 else: | 283 else: |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
423 if l and not l.startswith('#')] | 435 if l and not l.startswith('#')] |
424 | 436 |
425 return '*-%s' % ':'.join(disabled_filter_items) | 437 return '*-%s' % ':'.join(disabled_filter_items) |
426 | 438 |
427 #override | 439 #override |
428 def TearDown(self): | 440 def TearDown(self): |
429 """Clear the mappings created by SetUp.""" | 441 """Clear the mappings created by SetUp.""" |
430 if self._isolate_delegate: | 442 if self._isolate_delegate: |
431 self._isolate_delegate.Clear() | 443 self._isolate_delegate.Clear() |
432 | 444 |
OLD | NEW |