Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(698)

Side by Side Diff: build/util/lib/common/unittest_util.py

Issue 1522303002: Enforce ordering in FilterTestNames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make FilterTestNames return results in order Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 test_set = set()
141 # Test name must by matched by one positive pattern. 141 for pattern in positive_patterns:
142 for pattern in positive_patterns: 142 ptrn_tests = [test for test in all_tests
mikecase (-- gone --) 2015/12/15 19:20:28 nit: Would prefer if this was named pattern_tests
alexandermont 2015/12/15 19:37:53 if you do this, it makes line 144 too long
jbudorick 2015/12/15 19:38:54 I'd also prefer pattern_tests. You may need to han
143 if fnmatch.fnmatch(test, pattern): 143 if (fnmatch.fnmatch(test, pattern) and
144 break 144 not any(fnmatch(test, p) for p in negative_patterns) and
145 else: 145 test not in test_set)]
146 continue 146 tests.extend(ptrn_tests)
147 # Test name must not be matched by any negative patterns. 147 test_set.update(ptrn_tests)
148 for pattern in negative_patterns or []:
149 if fnmatch.fnmatch(test, pattern):
150 break
151 else:
152 tests += [test]
153 return tests 148 return tests
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698