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

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

Issue 1245623005: [test] Key variant flags by variant name everywhere. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« test/test262-es6/testcfg.py ('K') | « tools/run-tests.py ('k') | 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 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 17 matching lines...) Expand all
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 36
37 # Use this to run several variants of the tests. 37 # Use this to run several variants of the tests.
38 VARIANT_FLAGS = { 38 ALL_VARIANTS = [
39 "default": [], 39 ("default", []),
40 "stress": ["--stress-opt", "--always-opt"], 40 ("stress", ["--stress-opt", "--always-opt"]),
41 "turbofan": ["--turbo", "--always-opt"], 41 ("turbofan", ["--turbo", "--always-opt"]),
42 "nocrankshaft": ["--nocrankshaft"]} 42 ("nocrankshaft", ["--nocrankshaft"]),
43 ]
43 44
44 FAST_VARIANT_FLAGS = [ 45 # FAST_VARIANTS implies no --always-opt.
45 f for v, f in VARIANT_FLAGS.iteritems() if v in ["default", "turbofan"] 46 FAST_VARIANTS = [
47 ("default", []),
48 ("turbofan", ["--turbo"]),
46 ] 49 ]
47 50
51 DEFAULT_VARIANT = [
52 ("default", []),
53 ]
54
55 def FilterVariants(variants, variant_filter):
Jakob Kummerow 2015/07/27 14:36:53 nit: VariantsFilterBuilder would be a more appropr
56 return filter(lambda (v, f): v in variant_filter, variants)
57
58 class VariantFlagsBuilder(object):
59 def __init__(self, suite, variant_filter):
60 self.suite = suite
61 self.all_variants = FilterVariants(ALL_VARIANTS, variant_filter)
62 self.fast_variants = FilterVariants(FAST_VARIANTS, variant_filter)
63 self.default_variant = FilterVariants(DEFAULT_VARIANT, variant_filter)
64
65 def DefaultVariant(self, testcase):
Jakob Kummerow 2015/07/27 14:36:53 nit: this method and its friends below are private
66 """The variants to be run if the test case is marked with NO_VARIANTS."""
67 return self.default_variant
68
69 def FastVariants(self, testcase):
70 """The variants to be run if the test case is marked with FAST_VARIANTS."""
71 return self.fast_variants
72
73 def AllVariants(self, testcase):
74 """The variants to be run if the test case is not marked with a variants
75 modifier.
76 """
77 return self.all_variants
78
79 def __call__(self, testcase):
Jakob Kummerow 2015/07/27 14:36:53 nit: instead of messing with Python object interna
80 """Calculate the testing variants and flags for a test case of the
81 corresponding suite.
82
83 Returns: An iterable over variant tuples (name, list of flags).
Jakob Kummerow 2015/07/27 14:36:53 nit: IIUC this comment is a lie. It returns a call
84 """
85 if testcase.outcomes and statusfile.OnlyStandardVariant(
86 testcase.outcomes):
87 return self.DefaultVariant(testcase)
88 if testcase.outcomes and statusfile.OnlyFastVariants(testcase.outcomes):
89 return self.FastVariants(testcase)
90 return self.AllVariants(testcase)
91
92
48 class TestSuite(object): 93 class TestSuite(object):
49 94
50 @staticmethod 95 @staticmethod
51 def LoadTestSuite(root): 96 def LoadTestSuite(root):
52 name = root.split(os.path.sep)[-1] 97 name = root.split(os.path.sep)[-1]
53 f = None 98 f = None
54 try: 99 try:
55 (f, pathname, description) = imp.find_module("testcfg", [root]) 100 (f, pathname, description) = imp.find_module("testcfg", [root])
56 module = imp.load_module("testcfg", f, pathname, description) 101 module = imp.load_module("testcfg", f, pathname, description)
57 return module.GetSuite(name, root) 102 return module.GetSuite(name, root)
(...skipping 24 matching lines...) Expand all
82 # Used in the status file and for stdout printing. 127 # Used in the status file and for stdout printing.
83 def CommonTestName(self, testcase): 128 def CommonTestName(self, testcase):
84 if utils.IsWindows(): 129 if utils.IsWindows():
85 return testcase.path.replace("\\", "/") 130 return testcase.path.replace("\\", "/")
86 else: 131 else:
87 return testcase.path 132 return testcase.path
88 133
89 def ListTests(self, context): 134 def ListTests(self, context):
90 raise NotImplementedError 135 raise NotImplementedError
91 136
92 def VariantFlags(self, testcase, default_flags): 137 def VariantFlagsBuilder(self):
Jakob Kummerow 2015/07/27 14:36:53 nit: I don't like clashing names of unrelated thin
93 if testcase.outcomes and statusfile.OnlyStandardVariant(testcase.outcomes): 138 """The variant builder class to be used."""
94 return [[]] 139 return VariantFlagsBuilder
95 if testcase.outcomes and statusfile.OnlyFastVariants(testcase.outcomes): 140
96 # FAST_VARIANTS implies no --always-opt. 141 def VariantFlags(self, variant_filter):
Jakob Kummerow 2015/07/27 14:36:53 nit: this doesn't return flags any more, but a fun
97 return [ filter(lambda flag: flag != "--always-opt", f) 142 """Calculate the testing variants of this suite.
98 for f in filter(lambda flags: flags in FAST_VARIANT_FLAGS, 143
99 default_flags) ] 144 Args:
100 return default_flags 145 variant_filter: List of variant names to be run as specified by the test
146 runner.
147 Returns: A callable that returns an iterable over variant tuples (name,
148 list of flags).
149 """
150 return self.VariantFlagsBuilder()(self, variant_filter)
101 151
102 def DownloadData(self): 152 def DownloadData(self):
103 pass 153 pass
104 154
105 def ReadStatusFile(self, variables): 155 def ReadStatusFile(self, variables):
106 (self.rules, self.wildcards) = \ 156 (self.rules, self.wildcards) = \
107 statusfile.ReadStatusFile(self.status_file(), variables) 157 statusfile.ReadStatusFile(self.status_file(), variables)
108 158
109 def ReadTestCases(self, context): 159 def ReadTestCases(self, context):
110 self.tests = self.ListTests(context) 160 self.tests = self.ListTests(context)
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 tests.append(test) 328 tests.append(test)
279 tests.sort() 329 tests.sort()
280 return tests 330 return tests
281 331
282 def GetFlagsForTestCase(self, testcase, context): 332 def GetFlagsForTestCase(self, testcase, context):
283 return (testcase.flags + ["--gtest_filter=" + testcase.path] + 333 return (testcase.flags + ["--gtest_filter=" + testcase.path] +
284 ["--gtest_random_seed=%s" % context.random_seed] + 334 ["--gtest_random_seed=%s" % context.random_seed] +
285 ["--gtest_print_time=0"] + 335 ["--gtest_print_time=0"] +
286 context.mode_flags) 336 context.mode_flags)
287 337
288 def VariantFlags(self, testcase, default_flags): 338 def VariantFlags(self, variant_filter):
289 return [[]] 339 return lambda _: DEFAULT_VARIANT
290 340
291 def shell(self): 341 def shell(self):
292 return self.name 342 return self.name
OLDNEW
« test/test262-es6/testcfg.py ('K') | « tools/run-tests.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698