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

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: 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 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
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