| 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 threading |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 # TODO(jbudorick): Remove these once we're no longer parsing stdout to generate | 66 # TODO(jbudorick): Remove these once we're no longer parsing stdout to generate |
| 67 # results. | 67 # results. |
| 68 _RE_TEST_STATUS = re.compile( | 68 _RE_TEST_STATUS = re.compile( |
| 69 r'\[ +((?:RUN)|(?:FAILED)|(?:OK)|(?:CRASHED)) +\]' | 69 r'\[ +((?:RUN)|(?:FAILED)|(?:OK)|(?:CRASHED)) +\]' |
| 70 r' ?([^ ]+)?(?: \((\d+) ms\))?$') | 70 r' ?([^ ]+)?(?: \((\d+) ms\))?$') |
| 71 # Crash detection constants. | 71 # Crash detection constants. |
| 72 _RE_TEST_ERROR = re.compile(r'FAILURES!!! Tests run: \d+,' | 72 _RE_TEST_ERROR = re.compile(r'FAILURES!!! Tests run: \d+,' |
| 73 r' Failures: \d+, Errors: 1') | 73 r' Failures: \d+, Errors: 1') |
| 74 _RE_TEST_CURRENTLY_RUNNING = re.compile(r'\[ERROR:.*?\]' | 74 _RE_TEST_CURRENTLY_RUNNING = re.compile(r'\[ERROR:.*?\]' |
| 75 r' Currently running: (.*)') | 75 r' Currently running: (.*)') |
| 76 _RE_DISABLED = re.compile(r'DISABLED_') |
| 77 _RE_FLAKY = re.compile(r'FLAKY_') |
| 76 | 78 |
| 77 def ParseGTestListTests(raw_list): | 79 def ParseGTestListTests(raw_list): |
| 78 """Parses a raw test list as provided by --gtest_list_tests. | 80 """Parses a raw test list as provided by --gtest_list_tests. |
| 79 | 81 |
| 80 Args: | 82 Args: |
| 81 raw_list: The raw test listing with the following format: | 83 raw_list: The raw test listing with the following format: |
| 82 | 84 |
| 83 IPCChannelTest. | 85 IPCChannelTest. |
| 84 SendMessageInChannelConnected | 86 SendMessageInChannelConnected |
| 85 IPCSyncChannelTest. | 87 IPCSyncChannelTest. |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 # Split the tests into positive and negative patterns (gtest treats | 222 # Split the tests into positive and negative patterns (gtest treats |
| 221 # every pattern after the first '-' sign as an exclusion). | 223 # every pattern after the first '-' sign as an exclusion). |
| 222 positive_patterns = ':'.join(l for l in filter_lines if l[0] != '-') | 224 positive_patterns = ':'.join(l for l in filter_lines if l[0] != '-') |
| 223 negative_patterns = ':'.join(l[1:] for l in filter_lines if l[0] == '-') | 225 negative_patterns = ':'.join(l[1:] for l in filter_lines if l[0] == '-') |
| 224 if negative_patterns: | 226 if negative_patterns: |
| 225 negative_patterns = '-' + negative_patterns | 227 negative_patterns = '-' + negative_patterns |
| 226 | 228 |
| 227 # Join the filter lines into one, big --gtest_filter argument. | 229 # Join the filter lines into one, big --gtest_filter argument. |
| 228 return positive_patterns + negative_patterns | 230 return positive_patterns + negative_patterns |
| 229 | 231 |
| 232 def TestNameWithoutDisabledPrefix(test_name): |
| 233 """Modify the test name without disabled prefix if prefix 'DISABLED_' or |
| 234 'FLAKY_' presents. |
| 235 |
| 236 Args: |
| 237 test_name: The name of a test. |
| 238 Returns: |
| 239 A test name without prefix 'DISABLED_' or 'FLAKY_'. |
| 240 """ |
| 241 disabled_prefixes = [_RE_DISABLED, _RE_FLAKY] |
| 242 for dp in disabled_prefixes: |
| 243 test_name = dp.sub('', test_name) |
| 244 return test_name |
| 230 | 245 |
| 231 class GtestTestInstance(test_instance.TestInstance): | 246 class GtestTestInstance(test_instance.TestInstance): |
| 232 | 247 |
| 233 def __init__(self, args, data_deps_delegate, error_func): | 248 def __init__(self, args, data_deps_delegate, error_func): |
| 234 super(GtestTestInstance, self).__init__() | 249 super(GtestTestInstance, self).__init__() |
| 235 # TODO(jbudorick): Support multiple test suites. | 250 # TODO(jbudorick): Support multiple test suites. |
| 236 if len(args.suite_name) > 1: | 251 if len(args.suite_name) > 1: |
| 237 raise ValueError('Platform mode currently supports only 1 gtest suite') | 252 raise ValueError('Platform mode currently supports only 1 gtest suite') |
| 238 self._exe_dist_dir = None | 253 self._exe_dist_dir = None |
| 239 self._extract_test_list_from_filter = args.extract_test_list_from_filter | 254 self._extract_test_list_from_filter = args.extract_test_list_from_filter |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 gtest_filter_strings.append(self._gtest_filter) | 437 gtest_filter_strings.append(self._gtest_filter) |
| 423 | 438 |
| 424 filtered_test_list = test_list | 439 filtered_test_list = test_list |
| 425 # This lock is required because on older versions of Python | 440 # This lock is required because on older versions of Python |
| 426 # |unittest_util.FilterTestNames| use of |fnmatch| is not threadsafe. | 441 # |unittest_util.FilterTestNames| use of |fnmatch| is not threadsafe. |
| 427 with self._filter_tests_lock: | 442 with self._filter_tests_lock: |
| 428 for gtest_filter_string in gtest_filter_strings: | 443 for gtest_filter_string in gtest_filter_strings: |
| 429 logging.debug('Filtering tests using: %s', gtest_filter_string) | 444 logging.debug('Filtering tests using: %s', gtest_filter_string) |
| 430 filtered_test_list = unittest_util.FilterTestNames( | 445 filtered_test_list = unittest_util.FilterTestNames( |
| 431 filtered_test_list, gtest_filter_string) | 446 filtered_test_list, gtest_filter_string) |
| 447 |
| 448 if self._run_disabled and self._gtest_filter: |
| 449 out_filtered_test_list = list(set(test_list)-set(filtered_test_list)) |
| 450 for test in out_filtered_test_list: |
| 451 test_name_no_disabled = TestNameWithoutDisabledPrefix(test) |
| 452 if test_name_no_disabled != test and unittest_util.FilterTestNames( |
| 453 [test_name_no_disabled], self._gtest_filter): |
| 454 filtered_test_list.append(test) |
| 432 return filtered_test_list | 455 return filtered_test_list |
| 433 | 456 |
| 434 def _GenerateDisabledFilterString(self, disabled_prefixes): | 457 def _GenerateDisabledFilterString(self, disabled_prefixes): |
| 435 disabled_filter_items = [] | 458 disabled_filter_items = [] |
| 436 | 459 |
| 437 if disabled_prefixes is None: | 460 if disabled_prefixes is None: |
| 438 disabled_prefixes = ['FAILS_', 'PRE_', 'MANUAL_'] | 461 disabled_prefixes = ['FAILS_', 'PRE_', 'MANUAL_'] |
| 439 if not self._run_disabled: | 462 if not self._run_disabled: |
| 440 disabled_prefixes += ['DISABLED_', 'FLAKY_'] | 463 disabled_prefixes += ['DISABLED_', 'FLAKY_'] |
| 441 | 464 |
| 442 disabled_filter_items += ['%s*' % dp for dp in disabled_prefixes] | 465 disabled_filter_items += ['%s*' % dp for dp in disabled_prefixes] |
| 443 disabled_filter_items += ['*.%s*' % dp for dp in disabled_prefixes] | 466 disabled_filter_items += ['*.%s*' % dp for dp in disabled_prefixes] |
| 444 | 467 |
| 445 disabled_tests_file_path = os.path.join( | 468 disabled_tests_file_path = os.path.join( |
| 446 host_paths.DIR_SOURCE_ROOT, 'build', 'android', 'pylib', 'gtest', | 469 host_paths.DIR_SOURCE_ROOT, 'build', 'android', 'pylib', 'gtest', |
| 447 'filter', '%s_disabled' % self._suite) | 470 'filter', '%s_disabled' % self._suite) |
| 448 if disabled_tests_file_path and os.path.exists(disabled_tests_file_path): | 471 if disabled_tests_file_path and os.path.exists(disabled_tests_file_path): |
| 449 with open(disabled_tests_file_path) as disabled_tests_file: | 472 with open(disabled_tests_file_path) as disabled_tests_file: |
| 450 disabled_filter_items += [ | 473 disabled_filter_items += [ |
| 451 '%s' % l for l in (line.strip() for line in disabled_tests_file) | 474 '%s' % l for l in (line.strip() for line in disabled_tests_file) |
| 452 if l and not l.startswith('#')] | 475 if l and not l.startswith('#')] |
| 453 | 476 |
| 454 return '*-%s' % ':'.join(disabled_filter_items) | 477 return '*-%s' % ':'.join(disabled_filter_items) |
| 455 | 478 |
| 456 #override | 479 #override |
| 457 def TearDown(self): | 480 def TearDown(self): |
| 458 """Do nothing.""" | 481 """Do nothing.""" |
| 459 pass | 482 pass |
| 460 | 483 |
| OLD | NEW |