| 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 threading |
| 10 import xml.etree.ElementTree | 11 import xml.etree.ElementTree |
| 11 | 12 |
| 12 from devil.android import apk_helper | 13 from devil.android import apk_helper |
| 13 from pylib import constants | 14 from pylib import constants |
| 14 from pylib.constants import host_paths | 15 from pylib.constants import host_paths |
| 15 from pylib.base import base_test_result | 16 from pylib.base import base_test_result |
| 16 from pylib.base import test_instance | 17 from pylib.base import test_instance |
| 17 from pylib.utils import isolator | 18 from pylib.utils import isolator |
| 18 | 19 |
| 19 with host_paths.SysPath(host_paths.BUILD_COMMON_PATH): | 20 with host_paths.SysPath(host_paths.BUILD_COMMON_PATH): |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 def __init__(self, args, isolate_delegate, error_func): | 234 def __init__(self, args, isolate_delegate, error_func): |
| 234 super(GtestTestInstance, self).__init__() | 235 super(GtestTestInstance, self).__init__() |
| 235 # TODO(jbudorick): Support multiple test suites. | 236 # TODO(jbudorick): Support multiple test suites. |
| 236 if len(args.suite_name) > 1: | 237 if len(args.suite_name) > 1: |
| 237 raise ValueError('Platform mode currently supports only 1 gtest suite') | 238 raise ValueError('Platform mode currently supports only 1 gtest suite') |
| 238 self._exe_dist_dir = None | 239 self._exe_dist_dir = None |
| 239 self._extract_test_list_from_filter = args.extract_test_list_from_filter | 240 self._extract_test_list_from_filter = args.extract_test_list_from_filter |
| 240 self._shard_timeout = args.shard_timeout | 241 self._shard_timeout = args.shard_timeout |
| 241 self._store_tombstones = args.store_tombstones | 242 self._store_tombstones = args.store_tombstones |
| 242 self._suite = args.suite_name[0] | 243 self._suite = args.suite_name[0] |
| 244 self._filter_tests_lock = threading.Lock() |
| 243 | 245 |
| 244 # GYP: | 246 # GYP: |
| 245 if args.executable_dist_dir: | 247 if args.executable_dist_dir: |
| 246 self._exe_dist_dir = os.path.abspath(args.executable_dist_dir) | 248 self._exe_dist_dir = os.path.abspath(args.executable_dist_dir) |
| 247 else: | 249 else: |
| 248 # TODO(agrieve): Remove auto-detection once recipes pass flag explicitly. | 250 # TODO(agrieve): Remove auto-detection once recipes pass flag explicitly. |
| 249 exe_dist_dir = os.path.join(constants.GetOutDirectory(), | 251 exe_dist_dir = os.path.join(constants.GetOutDirectory(), |
| 250 '%s__dist' % self._suite) | 252 '%s__dist' % self._suite) |
| 251 | 253 |
| 252 if os.path.exists(exe_dist_dir): | 254 if os.path.exists(exe_dist_dir): |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 DISABLED_, FLAKY_, FAILS_, PRE_, and MANUAL_ | 423 DISABLED_, FLAKY_, FAILS_, PRE_, and MANUAL_ |
| 422 Returns: | 424 Returns: |
| 423 A filtered list of tests to run. | 425 A filtered list of tests to run. |
| 424 """ | 426 """ |
| 425 gtest_filter_strings = [ | 427 gtest_filter_strings = [ |
| 426 self._GenerateDisabledFilterString(disabled_prefixes)] | 428 self._GenerateDisabledFilterString(disabled_prefixes)] |
| 427 if self._gtest_filter: | 429 if self._gtest_filter: |
| 428 gtest_filter_strings.append(self._gtest_filter) | 430 gtest_filter_strings.append(self._gtest_filter) |
| 429 | 431 |
| 430 filtered_test_list = test_list | 432 filtered_test_list = test_list |
| 431 for gtest_filter_string in gtest_filter_strings: | 433 # This lock is required because on older versions of Python |
| 432 logging.debug('Filtering tests using: %s', gtest_filter_string) | 434 # |unittest_util.FilterTestNames| use of |fnmatch| is not threadsafe. |
| 433 filtered_test_list = unittest_util.FilterTestNames( | 435 with self._filter_tests_lock: |
| 434 filtered_test_list, gtest_filter_string) | 436 for gtest_filter_string in gtest_filter_strings: |
| 437 logging.debug('Filtering tests using: %s', gtest_filter_string) |
| 438 filtered_test_list = unittest_util.FilterTestNames( |
| 439 filtered_test_list, gtest_filter_string) |
| 435 return filtered_test_list | 440 return filtered_test_list |
| 436 | 441 |
| 437 def _GenerateDisabledFilterString(self, disabled_prefixes): | 442 def _GenerateDisabledFilterString(self, disabled_prefixes): |
| 438 disabled_filter_items = [] | 443 disabled_filter_items = [] |
| 439 | 444 |
| 440 if disabled_prefixes is None: | 445 if disabled_prefixes is None: |
| 441 disabled_prefixes = ['DISABLED_', 'FLAKY_', 'FAILS_', 'PRE_', 'MANUAL_'] | 446 disabled_prefixes = ['DISABLED_', 'FLAKY_', 'FAILS_', 'PRE_', 'MANUAL_'] |
| 442 disabled_filter_items += ['%s*' % dp for dp in disabled_prefixes] | 447 disabled_filter_items += ['%s*' % dp for dp in disabled_prefixes] |
| 443 disabled_filter_items += ['*.%s*' % dp for dp in disabled_prefixes] | 448 disabled_filter_items += ['*.%s*' % dp for dp in disabled_prefixes] |
| 444 | 449 |
| 445 disabled_tests_file_path = os.path.join( | 450 disabled_tests_file_path = os.path.join( |
| 446 host_paths.DIR_SOURCE_ROOT, 'build', 'android', 'pylib', 'gtest', | 451 host_paths.DIR_SOURCE_ROOT, 'build', 'android', 'pylib', 'gtest', |
| 447 'filter', '%s_disabled' % self._suite) | 452 'filter', '%s_disabled' % self._suite) |
| 448 if disabled_tests_file_path and os.path.exists(disabled_tests_file_path): | 453 if disabled_tests_file_path and os.path.exists(disabled_tests_file_path): |
| 449 with open(disabled_tests_file_path) as disabled_tests_file: | 454 with open(disabled_tests_file_path) as disabled_tests_file: |
| 450 disabled_filter_items += [ | 455 disabled_filter_items += [ |
| 451 '%s' % l for l in (line.strip() for line in disabled_tests_file) | 456 '%s' % l for l in (line.strip() for line in disabled_tests_file) |
| 452 if l and not l.startswith('#')] | 457 if l and not l.startswith('#')] |
| 453 | 458 |
| 454 return '*-%s' % ':'.join(disabled_filter_items) | 459 return '*-%s' % ':'.join(disabled_filter_items) |
| 455 | 460 |
| 456 #override | 461 #override |
| 457 def TearDown(self): | 462 def TearDown(self): |
| 458 """Clear the mappings created by SetUp.""" | 463 """Clear the mappings created by SetUp.""" |
| 459 if self._isolate_delegate: | 464 if self._isolate_delegate: |
| 460 self._isolate_delegate.Clear() | 465 self._isolate_delegate.Clear() |
| 461 | 466 |
| OLD | NEW |