Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 """Utilities for dealing with the python unittest module.""" | 5 """Utilities for dealing with the python unittest module.""" |
| 6 | 6 |
| 7 import fnmatch | 7 import fnmatch |
| 8 import sys | 8 import sys |
| 9 import unittest | 9 import unittest |
| 10 | 10 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 all_tests: List of test names. | 125 all_tests: List of test names. |
| 126 gtest_filter: Filter to apply. | 126 gtest_filter: Filter to apply. |
| 127 | 127 |
| 128 Returns: | 128 Returns: |
| 129 Filtered subset of the given list of test names. | 129 Filtered subset of the given list of test names. |
| 130 """ | 130 """ |
| 131 pattern_groups = gtest_filter.split('-') | 131 pattern_groups = gtest_filter.split('-') |
| 132 positive_patterns = ['*'] | 132 positive_patterns = ['*'] |
| 133 if pattern_groups[0]: | 133 if pattern_groups[0]: |
| 134 positive_patterns = pattern_groups[0].split(':') | 134 positive_patterns = pattern_groups[0].split(':') |
| 135 negative_patterns = None | 135 negative_patterns = [] |
| 136 if len(pattern_groups) > 1: | 136 if len(pattern_groups) > 1: |
| 137 negative_patterns = pattern_groups[1].split(':') | 137 negative_patterns = pattern_groups[1].split(':') |
| 138 | 138 |
| 139 tests = [] | 139 tests = [] |
| 140 for test in all_tests: | 140 for i in range(len(positive_patterns)): |
| 141 # Test name must by matched by one positive pattern. | 141 pt_tests = [test for test in all_tests |
|
mikecase (-- gone --)
2015/12/15 16:32:20
What does "pt" stand for?
| |
| 142 for pattern in positive_patterns: | 142 if (fnmatch.fnmatch(test, positive_patterns[i]) and |
| 143 if fnmatch.fnmatch(test, pattern): | 143 not any(fnmatch(test, p) for p in negative_patterns) and |
| 144 break | 144 not any(fnmatch(test, p) for p in positive_patterns[:i]))] |
|
jbudorick
2015/12/15 16:35:58
I think you could make tests a set instead of a li
| |
| 145 else: | 145 tests.extend(pt_tests) |
| 146 continue | |
| 147 # Test name must not be matched by any negative patterns. | |
| 148 for pattern in negative_patterns or []: | |
| 149 if fnmatch.fnmatch(test, pattern): | |
| 150 break | |
| 151 else: | |
| 152 tests += [test] | |
| 153 return tests | 146 return tests |
| OLD | NEW |