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

Side by Side Diff: tools/testrunner/local/testsuite.py

Issue 2203013002: [test] Enable test status filtering by variant (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Nits Created 4 years, 4 months 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
OLDNEW
1 # Copyright 2012 the V8 project authors. All rights reserved. 1 # Copyright 2012 the V8 project authors. All rights reserved.
2 # Redistribution and use in source and binary forms, with or without 2 # Redistribution and use in source and binary forms, with or without
3 # modification, are permitted provided that the following conditions are 3 # modification, are permitted provided that the following conditions are
4 # met: 4 # met:
5 # 5 #
6 # * Redistributions of source code must retain the above copyright 6 # * Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer. 7 # notice, this list of conditions and the following disclaimer.
8 # * Redistributions in binary form must reproduce the above 8 # * Redistributions in binary form must reproduce the above
9 # copyright notice, this list of conditions and the following 9 # copyright notice, this list of conditions and the following
10 # disclaimer in the documentation and/or other materials provided 10 # disclaimer in the documentation and/or other materials provided
(...skipping 15 matching lines...) Expand all
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 28
29 import imp 29 import imp
30 import os 30 import os
31 31
32 from . import commands 32 from . import commands
33 from . import statusfile 33 from . import statusfile
34 from . import utils 34 from . import utils
35 from ..objects import testcase 35 from ..objects import testcase
36 from variants import ALL_VARIANTS, ALL_VARIANT_FLAGS, FAST_VARIANT_FLAGS
36 37
37 # Use this to run several variants of the tests.
38 ALL_VARIANT_FLAGS = {
39 "default": [[]],
40 "stress": [["--stress-opt", "--always-opt"]],
41 "turbofan": [["--turbo"]],
42 "turbofan_opt": [["--turbo", "--always-opt"]],
43 "nocrankshaft": [["--nocrankshaft"]],
44 "ignition": [["--ignition"]],
45 "ignition_turbofan": [["--ignition-staging", "--turbo"]],
46 "preparser": [["--min-preparse-length=0"]],
47 }
48 38
49 # FAST_VARIANTS implies no --always-opt.
50 FAST_VARIANT_FLAGS = {
51 "default": [[]],
52 "stress": [["--stress-opt"]],
53 "turbofan": [["--turbo"]],
54 "nocrankshaft": [["--nocrankshaft"]],
55 "ignition": [["--ignition"]],
56 "ignition_turbofan": [["--ignition-staging", "--turbo"]],
57 "preparser": [["--min-preparse-length=0"]],
58 }
59
60 ALL_VARIANTS = set(["default", "stress", "turbofan", "turbofan_opt",
61 "nocrankshaft", "ignition", "ignition_turbofan",
62 "preparser"])
63 FAST_VARIANTS = set(["default", "turbofan"]) 39 FAST_VARIANTS = set(["default", "turbofan"])
64 STANDARD_VARIANT = set(["default"]) 40 STANDARD_VARIANT = set(["default"])
65 IGNITION_VARIANT = set(["ignition"]) 41 IGNITION_VARIANT = set(["ignition"])
66 42
67 43
68 class VariantGenerator(object): 44 class VariantGenerator(object):
69 def __init__(self, suite, variants): 45 def __init__(self, suite, variants):
70 self.suite = suite 46 self.suite = suite
71 self.all_variants = ALL_VARIANTS & variants 47 self.all_variants = ALL_VARIANTS & variants
72 self.fast_variants = FAST_VARIANTS & variants 48 self.fast_variants = FAST_VARIANTS & variants
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 variants: List of variant names to be run as specified by the test 122 variants: List of variant names to be run as specified by the test
147 runner. 123 runner.
148 Returns: An object of type VariantGenerator. 124 Returns: An object of type VariantGenerator.
149 """ 125 """
150 return self._VariantGeneratorFactory()(self, set(variants)) 126 return self._VariantGeneratorFactory()(self, set(variants))
151 127
152 def DownloadData(self): 128 def DownloadData(self):
153 pass 129 pass
154 130
155 def ReadStatusFile(self, variables): 131 def ReadStatusFile(self, variables):
156 (self.rules, self.wildcards) = \ 132 with open(self.status_file()) as f:
157 statusfile.ReadStatusFile(self.status_file(), variables) 133 self.rules, self.wildcards = (
134 statusfile.ReadStatusFile(f.read(), variables))
158 135
159 def ReadTestCases(self, context): 136 def ReadTestCases(self, context):
160 self.tests = self.ListTests(context) 137 self.tests = self.ListTests(context)
161 138
162 @staticmethod 139 @staticmethod
163 def _FilterSlow(slow, mode): 140 def _FilterSlow(slow, mode):
164 return (mode == "run" and not slow) or (mode == "skip" and slow) 141 return (mode == "run" and not slow) or (mode == "skip" and slow)
165 142
166 @staticmethod 143 @staticmethod
167 def _FilterPassFail(pass_fail, mode): 144 def _FilterPassFail(pass_fail, mode):
168 return (mode == "run" and not pass_fail) or (mode == "skip" and pass_fail) 145 return (mode == "run" and not pass_fail) or (mode == "skip" and pass_fail)
169 146
170 def FilterTestCasesByStatus(self, warn_unused_rules, 147 def FilterTestCasesByStatus(self, warn_unused_rules,
171 slow_tests="dontcare", 148 slow_tests="dontcare",
172 pass_fail_tests="dontcare"): 149 pass_fail_tests="dontcare",
150 variants=False):
151
152 # Use only variants-dependent rules and wildcards when filtering
153 # respective test cases and generic rules when filtering generic test
154 # cases.
155 if not variants:
156 rules = self.rules[""]
157 wildcards = self.wildcards[""]
158 else:
159 # We set rules and wildcards to a variant-specific version for each test
160 # below.
161 rules = {}
162 wildcards = {}
163
173 filtered = [] 164 filtered = []
165
166 # Remember used rules as tuples of (rule, variant), where variant is "" for
167 # variant-independent rules.
174 used_rules = set() 168 used_rules = set()
169
175 for t in self.tests: 170 for t in self.tests:
176 slow = False 171 slow = False
177 pass_fail = False 172 pass_fail = False
178 testname = self.CommonTestName(t) 173 testname = self.CommonTestName(t)
179 if testname in self.rules: 174 variant = t.variant or ""
180 used_rules.add(testname) 175 if variants:
176 rules = self.rules[variant]
177 wildcards = self.wildcards[variant]
178 if testname in rules:
179 used_rules.add((testname, variant))
181 # Even for skipped tests, as the TestCase object stays around and 180 # Even for skipped tests, as the TestCase object stays around and
182 # PrintReport() uses it. 181 # PrintReport() uses it.
183 t.outcomes = self.rules[testname] 182 t.outcomes |= rules[testname]
184 if statusfile.DoSkip(t.outcomes): 183 if statusfile.DoSkip(t.outcomes):
185 continue # Don't add skipped tests to |filtered|. 184 continue # Don't add skipped tests to |filtered|.
186 for outcome in t.outcomes: 185 for outcome in t.outcomes:
187 if outcome.startswith('Flags: '): 186 if outcome.startswith('Flags: '):
188 t.flags += outcome[7:].split() 187 t.flags += outcome[7:].split()
189 slow = statusfile.IsSlow(t.outcomes) 188 slow = statusfile.IsSlow(t.outcomes)
190 pass_fail = statusfile.IsPassOrFail(t.outcomes) 189 pass_fail = statusfile.IsPassOrFail(t.outcomes)
191 skip = False 190 skip = False
192 for rule in self.wildcards: 191 for rule in wildcards:
193 assert rule[-1] == '*' 192 assert rule[-1] == '*'
194 if testname.startswith(rule[:-1]): 193 if testname.startswith(rule[:-1]):
195 used_rules.add(rule) 194 used_rules.add((rule, variant))
196 t.outcomes |= self.wildcards[rule] 195 t.outcomes |= wildcards[rule]
197 if statusfile.DoSkip(t.outcomes): 196 if statusfile.DoSkip(t.outcomes):
198 skip = True 197 skip = True
199 break # "for rule in self.wildcards" 198 break # "for rule in wildcards"
200 slow = slow or statusfile.IsSlow(t.outcomes) 199 slow = slow or statusfile.IsSlow(t.outcomes)
201 pass_fail = pass_fail or statusfile.IsPassOrFail(t.outcomes) 200 pass_fail = pass_fail or statusfile.IsPassOrFail(t.outcomes)
202 if (skip 201 if (skip
203 or self._FilterSlow(slow, slow_tests) 202 or self._FilterSlow(slow, slow_tests)
204 or self._FilterPassFail(pass_fail, pass_fail_tests)): 203 or self._FilterPassFail(pass_fail, pass_fail_tests)):
205 continue # "for t in self.tests" 204 continue # "for t in self.tests"
206 filtered.append(t) 205 filtered.append(t)
207 self.tests = filtered 206 self.tests = filtered
208 207
209 if not warn_unused_rules: 208 if not warn_unused_rules:
210 return 209 return
211 210
212 for rule in self.rules: 211 if not variants:
213 if rule not in used_rules: 212 for rule in self.rules[""]:
214 print("Unused rule: %s -> %s" % (rule, self.rules[rule])) 213 if (rule, "") not in used_rules:
215 for rule in self.wildcards: 214 print("Unused rule: %s -> %s (variant independent)" % (
216 if rule not in used_rules: 215 rule, self.rules[""][rule]))
217 print("Unused rule: %s -> %s" % (rule, self.wildcards[rule])) 216 for rule in self.wildcards[""]:
217 if (rule, "") not in used_rules:
218 print("Unused rule: %s -> %s (variant independent)" % (
219 rule, self.wildcards[""][rule]))
220 else:
221 for variant in ALL_VARIANTS:
222 for rule in self.rules[variant]:
223 if (rule, variant) not in used_rules:
224 print("Unused rule: %s -> %s (variant: %s)" % (
225 rule, self.rules[variant][rule], variant))
226 for rule in self.wildcards[variant]:
227 if (rule, variant) not in used_rules:
228 print("Unused rule: %s -> %s (variant: %s)" % (
229 rule, self.wildcards[variant][rule], variant))
230
218 231
219 def FilterTestCasesByArgs(self, args): 232 def FilterTestCasesByArgs(self, args):
220 """Filter test cases based on command-line arguments. 233 """Filter test cases based on command-line arguments.
221 234
222 An argument with an asterisk in the end will match all test cases 235 An argument with an asterisk in the end will match all test cases
223 that have the argument as a prefix. Without asterisk, only exact matches 236 that have the argument as a prefix. Without asterisk, only exact matches
224 will be used with the exeption of the test-suite name as argument. 237 will be used with the exeption of the test-suite name as argument.
225 """ 238 """
226 filtered = [] 239 filtered = []
227 globs = [] 240 globs = []
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 return (testcase.flags + ["--gtest_filter=" + testcase.path] + 343 return (testcase.flags + ["--gtest_filter=" + testcase.path] +
331 ["--gtest_random_seed=%s" % context.random_seed] + 344 ["--gtest_random_seed=%s" % context.random_seed] +
332 ["--gtest_print_time=0"] + 345 ["--gtest_print_time=0"] +
333 context.mode_flags) 346 context.mode_flags)
334 347
335 def _VariantGeneratorFactory(self): 348 def _VariantGeneratorFactory(self):
336 return StandardVariantGenerator 349 return StandardVariantGenerator
337 350
338 def shell(self): 351 def shell(self):
339 return self.name 352 return self.name
OLDNEW
« no previous file with comments | « tools/testrunner/local/statusfile_unittest.py ('k') | tools/testrunner/local/testsuite_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698