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 |
11 | 11 |
12 from devil.android import apk_helper | 12 from devil.android import apk_helper |
13 from pylib import constants | 13 from pylib import constants |
14 from pylib.constants import host_paths | 14 from pylib.constants import host_paths |
15 from pylib.base import base_test_result | 15 from pylib.base import base_test_result |
16 from pylib.base import test_instance | 16 from pylib.base import test_instance |
17 from pylib.utils import isolator | |
18 | 17 |
19 with host_paths.SysPath(host_paths.BUILD_COMMON_PATH): | 18 with host_paths.SysPath(host_paths.BUILD_COMMON_PATH): |
20 import unittest_util # pylint: disable=import-error | 19 import unittest_util # pylint: disable=import-error |
21 | 20 |
22 | 21 |
23 BROWSER_TEST_SUITES = [ | 22 BROWSER_TEST_SUITES = [ |
24 'components_browsertests', | 23 'components_browsertests', |
25 'content_browsertests', | 24 'content_browsertests', |
26 ] | 25 ] |
27 | 26 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 negative_patterns = ':'.join(l[1:] for l in filter_lines if l[0] == '-') | 222 negative_patterns = ':'.join(l[1:] for l in filter_lines if l[0] == '-') |
224 if negative_patterns: | 223 if negative_patterns: |
225 negative_patterns = '-' + negative_patterns | 224 negative_patterns = '-' + negative_patterns |
226 | 225 |
227 # Join the filter lines into one, big --gtest_filter argument. | 226 # Join the filter lines into one, big --gtest_filter argument. |
228 return positive_patterns + negative_patterns | 227 return positive_patterns + negative_patterns |
229 | 228 |
230 | 229 |
231 class GtestTestInstance(test_instance.TestInstance): | 230 class GtestTestInstance(test_instance.TestInstance): |
232 | 231 |
233 def __init__(self, args, isolate_delegate, error_func): | 232 def __init__(self, args, data_deps_delegate, error_func): |
234 super(GtestTestInstance, self).__init__() | 233 super(GtestTestInstance, self).__init__() |
235 # TODO(jbudorick): Support multiple test suites. | 234 # TODO(jbudorick): Support multiple test suites. |
236 if len(args.suite_name) > 1: | 235 if len(args.suite_name) > 1: |
237 raise ValueError('Platform mode currently supports only 1 gtest suite') | 236 raise ValueError('Platform mode currently supports only 1 gtest suite') |
238 self._exe_dist_dir = None | 237 self._exe_dist_dir = None |
239 self._extract_test_list_from_filter = args.extract_test_list_from_filter | 238 self._extract_test_list_from_filter = args.extract_test_list_from_filter |
240 self._shard_timeout = args.shard_timeout | 239 self._shard_timeout = args.shard_timeout |
241 self._store_tombstones = args.store_tombstones | 240 self._store_tombstones = args.store_tombstones |
242 self._suite = args.suite_name[0] | 241 self._suite = args.suite_name[0] |
243 | 242 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 | 279 |
281 self._data_deps = [] | 280 self._data_deps = [] |
282 if args.test_filter: | 281 if args.test_filter: |
283 self._gtest_filter = args.test_filter | 282 self._gtest_filter = args.test_filter |
284 elif args.test_filter_file: | 283 elif args.test_filter_file: |
285 with open(args.test_filter_file, 'r') as f: | 284 with open(args.test_filter_file, 'r') as f: |
286 self._gtest_filter = ConvertTestFilterFileIntoGTestFilterArgument(f) | 285 self._gtest_filter = ConvertTestFilterFileIntoGTestFilterArgument(f) |
287 else: | 286 else: |
288 self._gtest_filter = None | 287 self._gtest_filter = None |
289 | 288 |
290 if (args.isolate_file_path and | 289 self._data_deps_delegate = data_deps_delegate |
291 not isolator.IsIsolateEmpty(args.isolate_file_path)): | 290 self._runtime_deps_path = args.runtime_deps_path |
292 self._isolate_abs_path = os.path.abspath(args.isolate_file_path) | 291 if not self._runtime_deps_path: |
293 self._isolate_delegate = isolate_delegate | 292 logging.warning('No data dependencies will be pushed.') |
294 self._isolated_abs_path = os.path.join( | |
295 constants.GetOutDirectory(), '%s.isolated' % self._suite) | |
296 else: | |
297 logging.warning('%s isolate file provided. No data deps will be pushed.', | |
298 'Empty' if args.isolate_file_path else 'No') | |
299 self._isolate_delegate = None | |
300 | 293 |
301 if args.app_data_files: | 294 if args.app_data_files: |
302 self._app_data_files = args.app_data_files | 295 self._app_data_files = args.app_data_files |
303 if args.app_data_file_dir: | 296 if args.app_data_file_dir: |
304 self._app_data_file_dir = args.app_data_file_dir | 297 self._app_data_file_dir = args.app_data_file_dir |
305 else: | 298 else: |
306 self._app_data_file_dir = tempfile.mkdtemp() | 299 self._app_data_file_dir = tempfile.mkdtemp() |
307 logging.critical('Saving app files to %s', self._app_data_file_dir) | 300 logging.critical('Saving app files to %s', self._app_data_file_dir) |
308 else: | 301 else: |
309 self._app_data_files = None | 302 self._app_data_files = None |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 def extract_test_list_from_filter(self): | 379 def extract_test_list_from_filter(self): |
387 return self._extract_test_list_from_filter | 380 return self._extract_test_list_from_filter |
388 | 381 |
389 #override | 382 #override |
390 def TestType(self): | 383 def TestType(self): |
391 return 'gtest' | 384 return 'gtest' |
392 | 385 |
393 #override | 386 #override |
394 def SetUp(self): | 387 def SetUp(self): |
395 """Map data dependencies via isolate.""" | 388 """Map data dependencies via isolate.""" |
396 if self._isolate_delegate: | 389 self._data_deps.extend( |
397 self._isolate_delegate.Remap( | 390 self._data_deps_delegate(self._runtime_deps_path)) |
398 self._isolate_abs_path, self._isolated_abs_path) | |
399 self._isolate_delegate.PurgeExcluded(_DEPS_EXCLUSION_LIST) | |
400 self._isolate_delegate.MoveOutputDeps() | |
401 dest_dir = None | |
402 self._data_deps.extend([ | |
403 (self._isolate_delegate.isolate_deps_dir, dest_dir)]) | |
404 | |
405 | 391 |
406 def GetDataDependencies(self): | 392 def GetDataDependencies(self): |
407 """Returns the test suite's data dependencies. | 393 """Returns the test suite's data dependencies. |
408 | 394 |
409 Returns: | 395 Returns: |
410 A list of (host_path, device_path) tuples to push. If device_path is | 396 A list of (host_path, device_path) tuples to push. If device_path is |
411 None, the client is responsible for determining where to push the file. | 397 None, the client is responsible for determining where to push the file. |
412 """ | 398 """ |
413 return self._data_deps | 399 return self._data_deps |
414 | 400 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 if disabled_tests_file_path and os.path.exists(disabled_tests_file_path): | 434 if disabled_tests_file_path and os.path.exists(disabled_tests_file_path): |
449 with open(disabled_tests_file_path) as disabled_tests_file: | 435 with open(disabled_tests_file_path) as disabled_tests_file: |
450 disabled_filter_items += [ | 436 disabled_filter_items += [ |
451 '%s' % l for l in (line.strip() for line in disabled_tests_file) | 437 '%s' % l for l in (line.strip() for line in disabled_tests_file) |
452 if l and not l.startswith('#')] | 438 if l and not l.startswith('#')] |
453 | 439 |
454 return '*-%s' % ':'.join(disabled_filter_items) | 440 return '*-%s' % ':'.join(disabled_filter_items) |
455 | 441 |
456 #override | 442 #override |
457 def TearDown(self): | 443 def TearDown(self): |
458 """Clear the mappings created by SetUp.""" | 444 """Do nothing.""" |
459 if self._isolate_delegate: | 445 pass |
460 self._isolate_delegate.Clear() | |
461 | 446 |
OLD | NEW |