| 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._extract_test_list_from_filter = args.extract_test_list_from_filter | 237 self._extract_test_list_from_filter = args.extract_test_list_from_filter |
| 239 self._shard_timeout = args.shard_timeout | 238 self._shard_timeout = args.shard_timeout |
| 240 self._suite = args.suite_name[0] | 239 self._suite = args.suite_name[0] |
| 241 self._exe_dist_dir = None | 240 self._exe_dist_dir = None |
| 242 | 241 |
| 243 # GYP: | 242 # GYP: |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 278 |
| 280 self._data_deps = [] | 279 self._data_deps = [] |
| 281 if args.test_filter: | 280 if args.test_filter: |
| 282 self._gtest_filter = args.test_filter | 281 self._gtest_filter = args.test_filter |
| 283 elif args.test_filter_file: | 282 elif args.test_filter_file: |
| 284 with open(args.test_filter_file, 'r') as f: | 283 with open(args.test_filter_file, 'r') as f: |
| 285 self._gtest_filter = ConvertTestFilterFileIntoGTestFilterArgument(f) | 284 self._gtest_filter = ConvertTestFilterFileIntoGTestFilterArgument(f) |
| 286 else: | 285 else: |
| 287 self._gtest_filter = None | 286 self._gtest_filter = None |
| 288 | 287 |
| 289 if (args.isolate_file_path and | 288 self._data_deps_delegate = data_deps_delegate |
| 290 not isolator.IsIsolateEmpty(args.isolate_file_path)): | 289 self._isolate_abs_path = args.isolate_file_path |
| 291 self._isolate_abs_path = os.path.abspath(args.isolate_file_path) | 290 if not self._isolate_abs_path: |
| 292 self._isolate_delegate = isolate_delegate | 291 logging.warning('No isolate file provided. No data deps will be pushed.') |
| 293 self._isolated_abs_path = os.path.join( | |
| 294 constants.GetOutDirectory(), '%s.isolated' % self._suite) | |
| 295 else: | |
| 296 logging.warning('%s isolate file provided. No data deps will be pushed.', | |
| 297 'Empty' if args.isolate_file_path else 'No') | |
| 298 self._isolate_delegate = None | |
| 299 | 292 |
| 300 if args.app_data_files: | 293 if args.app_data_files: |
| 301 self._app_data_files = args.app_data_files | 294 self._app_data_files = args.app_data_files |
| 302 if args.app_data_file_dir: | 295 if args.app_data_file_dir: |
| 303 self._app_data_file_dir = args.app_data_file_dir | 296 self._app_data_file_dir = args.app_data_file_dir |
| 304 else: | 297 else: |
| 305 self._app_data_file_dir = tempfile.mkdtemp() | 298 self._app_data_file_dir = tempfile.mkdtemp() |
| 306 logging.critical('Saving app files to %s', self._app_data_file_dir) | 299 logging.critical('Saving app files to %s', self._app_data_file_dir) |
| 307 else: | 300 else: |
| 308 self._app_data_files = None | 301 self._app_data_files = None |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 def extract_test_list_from_filter(self): | 374 def extract_test_list_from_filter(self): |
| 382 return self._extract_test_list_from_filter | 375 return self._extract_test_list_from_filter |
| 383 | 376 |
| 384 #override | 377 #override |
| 385 def TestType(self): | 378 def TestType(self): |
| 386 return 'gtest' | 379 return 'gtest' |
| 387 | 380 |
| 388 #override | 381 #override |
| 389 def SetUp(self): | 382 def SetUp(self): |
| 390 """Map data dependencies via isolate.""" | 383 """Map data dependencies via isolate.""" |
| 391 if self._isolate_delegate: | 384 self._data_deps.extend( |
| 392 self._isolate_delegate.Remap( | 385 self._data_deps_delegate(self._isolate_abs_path)) |
| 393 self._isolate_abs_path, self._isolated_abs_path) | |
| 394 self._isolate_delegate.PurgeExcluded(_DEPS_EXCLUSION_LIST) | |
| 395 self._isolate_delegate.MoveOutputDeps() | |
| 396 dest_dir = None | |
| 397 self._data_deps.extend([ | |
| 398 (self._isolate_delegate.isolate_deps_dir, dest_dir)]) | |
| 399 | |
| 400 | 386 |
| 401 def GetDataDependencies(self): | 387 def GetDataDependencies(self): |
| 402 """Returns the test suite's data dependencies. | 388 """Returns the test suite's data dependencies. |
| 403 | 389 |
| 404 Returns: | 390 Returns: |
| 405 A list of (host_path, device_path) tuples to push. If device_path is | 391 A list of (host_path, device_path) tuples to push. If device_path is |
| 406 None, the client is responsible for determining where to push the file. | 392 None, the client is responsible for determining where to push the file. |
| 407 """ | 393 """ |
| 408 return self._data_deps | 394 return self._data_deps |
| 409 | 395 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 if disabled_tests_file_path and os.path.exists(disabled_tests_file_path): | 429 if disabled_tests_file_path and os.path.exists(disabled_tests_file_path): |
| 444 with open(disabled_tests_file_path) as disabled_tests_file: | 430 with open(disabled_tests_file_path) as disabled_tests_file: |
| 445 disabled_filter_items += [ | 431 disabled_filter_items += [ |
| 446 '%s' % l for l in (line.strip() for line in disabled_tests_file) | 432 '%s' % l for l in (line.strip() for line in disabled_tests_file) |
| 447 if l and not l.startswith('#')] | 433 if l and not l.startswith('#')] |
| 448 | 434 |
| 449 return '*-%s' % ':'.join(disabled_filter_items) | 435 return '*-%s' % ':'.join(disabled_filter_items) |
| 450 | 436 |
| 451 #override | 437 #override |
| 452 def TearDown(self): | 438 def TearDown(self): |
| 453 """Clear the mappings created by SetUp.""" | 439 """Do nothing.""" |
| 454 if self._isolate_delegate: | 440 pass |
| 455 self._isolate_delegate.Clear() | |
| 456 | 441 |
| OLD | NEW |