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

Side by Side Diff: test/test262/testcfg.py

Issue 1766503002: Make test262 test runner check for which exception is thrown (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Better factoring Created 4 years, 9 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
« no previous file with comments | « test/simdjs/testcfg.py ('k') | test/webkit/testcfg.py » ('j') | 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 fullpath = os.path.join(dirname, filename) 122 fullpath = os.path.join(dirname, filename)
123 relpath = fullpath[len(self.testroot) + 1 : -3] 123 relpath = fullpath[len(self.testroot) + 1 : -3]
124 testname = relpath.replace(os.path.sep, "/") 124 testname = relpath.replace(os.path.sep, "/")
125 case = testcase.TestCase(self, testname) 125 case = testcase.TestCase(self, testname)
126 tests.append(case) 126 tests.append(case)
127 return tests 127 return tests
128 128
129 def GetFlagsForTestCase(self, testcase, context): 129 def GetFlagsForTestCase(self, testcase, context):
130 return (testcase.flags + context.mode_flags + self.harness + 130 return (testcase.flags + context.mode_flags + self.harness +
131 self.GetIncludesForTest(testcase) + ["--harmony"] + 131 self.GetIncludesForTest(testcase) + ["--harmony"] +
132 [os.path.join(self.testroot, testcase.path + ".js")]) 132 [os.path.join(self.testroot, testcase.path + ".js")] +
133 (["--throws"] if "negative" in self.GetTestRecord(testcase) else []) )
133 134
134 def _VariantGeneratorFactory(self): 135 def _VariantGeneratorFactory(self):
135 return Test262VariantGenerator 136 return Test262VariantGenerator
136 137
137 def LoadParseTestRecord(self): 138 def LoadParseTestRecord(self):
138 if not self.ParseTestRecord: 139 if not self.ParseTestRecord:
139 root = os.path.join(self.root, *TEST_262_TOOLS_PATH) 140 root = os.path.join(self.root, *TEST_262_TOOLS_PATH)
140 f = None 141 f = None
141 try: 142 try:
142 (f, pathname, description) = imp.find_module("parseTestRecord", [root]) 143 (f, pathname, description) = imp.find_module("parseTestRecord", [root])
143 module = imp.load_module("parseTestRecord", f, pathname, description) 144 module = imp.load_module("parseTestRecord", f, pathname, description)
144 self.ParseTestRecord = module.parseTestRecord 145 self.ParseTestRecord = module.parseTestRecord
145 except: 146 except:
146 raise ImportError("Cannot load parseTestRecord; you may need to " 147 raise ImportError("Cannot load parseTestRecord; you may need to "
147 "--download-data for test262") 148 "gclient sync for test262")
148 finally: 149 finally:
149 if f: 150 if f:
150 f.close() 151 f.close()
151 return self.ParseTestRecord 152 return self.ParseTestRecord
152 153
153 def GetTestRecord(self, testcase): 154 def GetTestRecord(self, testcase):
154 if not hasattr(testcase, "test_record"): 155 if not hasattr(testcase, "test_record"):
155 ParseTestRecord = self.LoadParseTestRecord() 156 ParseTestRecord = self.LoadParseTestRecord()
156 testcase.test_record = ParseTestRecord(self.GetSourceForTest(testcase), 157 testcase.test_record = ParseTestRecord(self.GetSourceForTest(testcase),
157 testcase.path) 158 testcase.path)
158 return testcase.test_record 159 return testcase.test_record
159 160
160 def GetIncludesForTest(self, testcase): 161 def GetIncludesForTest(self, testcase):
161 test_record = self.GetTestRecord(testcase) 162 test_record = self.GetTestRecord(testcase)
162 if "includes" in test_record: 163 if "includes" in test_record:
163 includes = [os.path.join(self.harnesspath, f) 164 includes = [os.path.join(self.harnesspath, f)
164 for f in test_record["includes"]] 165 for f in test_record["includes"]]
165 else: 166 else:
166 includes = [] 167 includes = []
167 return includes 168 return includes
168 169
169 def GetSourceForTest(self, testcase): 170 def GetSourceForTest(self, testcase):
170 filename = os.path.join(self.testroot, testcase.path + ".js") 171 filename = os.path.join(self.testroot, testcase.path + ".js")
171 with open(filename) as f: 172 with open(filename) as f:
172 return f.read() 173 return f.read()
173 174
174 def IsNegativeTest(self, testcase): 175 def _ParseException(self, str):
176 for line in str.split("\n")[::-1]:
177 if line and not line[0].isspace() and ":" in line:
178 return line.split(":")[0]
179
180
181 def IsFailureOutput(self, testcase):
182 output = testcase.output
175 test_record = self.GetTestRecord(testcase) 183 test_record = self.GetTestRecord(testcase)
176 return "negative" in test_record
177
178 def IsFailureOutput(self, output, testpath):
179 if output.exit_code != 0: 184 if output.exit_code != 0:
180 return True 185 return True
186 if "negative" in test_record:
187 if self._ParseException(output.stdout) != test_record["negative"]:
188 return True
181 return "FAILED!" in output.stdout 189 return "FAILED!" in output.stdout
182 190
183 def HasUnexpectedOutput(self, testcase): 191 def HasUnexpectedOutput(self, testcase):
184 outcome = self.GetOutcome(testcase) 192 outcome = self.GetOutcome(testcase)
185 if (statusfile.FAIL_SLOPPY in testcase.outcomes and 193 if (statusfile.FAIL_SLOPPY in testcase.outcomes and
186 "--use-strict" not in testcase.flags): 194 "--use-strict" not in testcase.flags):
187 return outcome != statusfile.FAIL 195 return outcome != statusfile.FAIL
188 return not outcome in (testcase.outcomes or [statusfile.PASS]) 196 return not outcome in (testcase.outcomes or [statusfile.PASS])
189 197
190 def DownloadData(self): 198 def DownloadData(self):
(...skipping 15 matching lines...) Expand all
206 # data folder. 214 # data folder.
207 if os.path.exists(ARCHIVE) and not os.path.exists(DATA): 215 if os.path.exists(ARCHIVE) and not os.path.exists(DATA):
208 print "Extracting archive..." 216 print "Extracting archive..."
209 tar = tarfile.open(ARCHIVE) 217 tar = tarfile.open(ARCHIVE)
210 tar.extractall(path=os.path.dirname(ARCHIVE)) 218 tar.extractall(path=os.path.dirname(ARCHIVE))
211 tar.close() 219 tar.close()
212 220
213 221
214 def GetSuite(name, root): 222 def GetSuite(name, root):
215 return Test262TestSuite(name, root) 223 return Test262TestSuite(name, root)
OLDNEW
« no previous file with comments | « test/simdjs/testcfg.py ('k') | test/webkit/testcfg.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698