Chromium Code Reviews| Index: test/test262/testcfg.py |
| diff --git a/test/test262/testcfg.py b/test/test262/testcfg.py |
| index d8123968fca0578e35855b0192e580944322656f..acc268ff4d392b5551861ca0ab544da36b17ac36 100644 |
| --- a/test/test262/testcfg.py |
| +++ b/test/test262/testcfg.py |
| @@ -27,6 +27,7 @@ |
| import imp |
| +import itertools |
| import os |
| import re |
| import sys |
| @@ -47,6 +48,7 @@ TEST_262_NATIVE_FILES = ["detachArrayBuffer.js"] |
| TEST_262_SUITE_PATH = ["data", "test"] |
| TEST_262_HARNESS_PATH = ["data", "harness"] |
| TEST_262_TOOLS_PATH = ["harness", "src"] |
| +TEST_262_LOCAL_TESTS_PATH = ["local-tests", "test"] |
| sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), |
| *TEST_262_TOOLS_PATH)) |
| @@ -101,6 +103,10 @@ class Test262VariantGenerator(testsuite.VariantGenerator): |
| class Test262TestSuite(testsuite.TestSuite): |
| + # Match the (...) in '/path/to/v8/test/test262/subdir/test/(...).js' |
| + # In practice, subdir is data or local-tests |
| + RELPATH_REGEXP = re.compile( |
|
Michael Achenbach
2017/01/06 09:26:02
nit: Maybe move it even more top-level, right next
Dan Ehrenberg
2017/01/06 09:58:10
Done.
|
| + r'.*[\\/]test[\\/]test262[\\/][^\\/]+[\\/]test[\\/](.*)\.js') |
| def __init__(self, name, root): |
| super(Test262TestSuite, self).__init__(name, root) |
| @@ -109,11 +115,14 @@ class Test262TestSuite(testsuite.TestSuite): |
| self.harness = [os.path.join(self.harnesspath, f) |
| for f in TEST_262_HARNESS_FILES] |
| self.harness += [os.path.join(self.root, "harness-adapt.js")] |
| + self.localtestroot = os.path.join(self.root, *TEST_262_LOCAL_TESTS_PATH) |
| self.ParseTestRecord = None |
| def ListTests(self, context): |
| tests = [] |
| - for dirname, dirs, files in os.walk(self.testroot): |
| + testnames = set() |
| + for dirname, dirs, files in itertools.chain(os.walk(self.testroot), |
| + os.walk(self.localtestroot)): |
| for dotted in [x for x in dirs if x.startswith(".")]: |
| dirs.remove(dotted) |
| if context.noi18n and "intl402" in dirs: |
| @@ -121,19 +130,20 @@ class Test262TestSuite(testsuite.TestSuite): |
| dirs.sort() |
| files.sort() |
| for filename in files: |
| - if filename.endswith(".js") and not filename.endswith("_FIXTURE.js"): |
| - fullpath = os.path.join(dirname, filename) |
| - relpath = fullpath[len(self.testroot) + 1 : -3] |
| - testname = relpath.replace(os.path.sep, "/") |
| - case = testcase.TestCase(self, testname) |
| - tests.append(case) |
| - return tests |
| + if not filename.endswith(".js"): |
| + continue |
| + if filename.endswith("_FIXTURE.js"): |
| + continue |
| + fullpath = os.path.join(dirname, filename) |
| + relpath = re.match(Test262TestSuite.RELPATH_REGEXP, fullpath).group(1) |
| + testnames.add(relpath.replace(os.path.sep, "/")) |
| + return [testcase.TestCase(self, testname) for testname in testnames] |
| def GetFlagsForTestCase(self, testcase, context): |
| return (testcase.flags + context.mode_flags + self.harness + |
| self.GetIncludesForTest(testcase) + ["--harmony"] + |
| (["--module"] if "module" in self.GetTestRecord(testcase) else []) + |
| - [os.path.join(self.testroot, testcase.path + ".js")] + |
| + [self.GetPathForTest(testcase)] + |
| (["--throws"] if "negative" in self.GetTestRecord(testcase) |
| else []) + |
| (["--allow-natives-syntax"] |
| @@ -179,9 +189,14 @@ class Test262TestSuite(testsuite.TestSuite): |
| includes = [] |
| return includes |
| + def GetPathForTest(self, testcase): |
| + filename = os.path.join(self.localtestroot, testcase.path + ".js") |
| + if not os.path.exists(filename): |
| + filename = os.path.join(self.testroot, testcase.path + ".js") |
| + return filename |
| + |
| def GetSourceForTest(self, testcase): |
| - filename = os.path.join(self.testroot, testcase.path + ".js") |
| - with open(filename) as f: |
| + with open(self.GetPathForTest(testcase)) as f: |
| return f.read() |
| def _ParseException(self, str): |