diff options
Diffstat (limited to 'src/3rdparty/v8/test/preparser')
-rw-r--r-- | src/3rdparty/v8/test/preparser/preparser.status | 5 | ||||
-rw-r--r-- | src/3rdparty/v8/test/preparser/strict-identifiers.pyt | 2 | ||||
-rw-r--r-- | src/3rdparty/v8/test/preparser/testcfg.py | 106 |
3 files changed, 107 insertions, 6 deletions
diff --git a/src/3rdparty/v8/test/preparser/preparser.status b/src/3rdparty/v8/test/preparser/preparser.status index 6f15fed..40c5caf 100644 --- a/src/3rdparty/v8/test/preparser/preparser.status +++ b/src/3rdparty/v8/test/preparser/preparser.status @@ -31,3 +31,8 @@ prefix preparser # escapes (we need to parse to distinguish octal escapes from valid # back-references). strict-octal-regexp: FAIL + +[ $arch == android_arm || $arch == android_ia32 ] +# Remove this once the issue above is fixed. Android test runner does not +# handle "FAIL" test expectation correctly. +strict-octal-regexp: SKIP diff --git a/src/3rdparty/v8/test/preparser/strict-identifiers.pyt b/src/3rdparty/v8/test/preparser/strict-identifiers.pyt index aa3d521..f979088 100644 --- a/src/3rdparty/v8/test/preparser/strict-identifiers.pyt +++ b/src/3rdparty/v8/test/preparser/strict-identifiers.pyt @@ -285,4 +285,4 @@ for reserved_word in reserved_words + strict_reserved_words: # Future reserved words in strict mode behave like normal identifiers # in a non strict context. for reserved_word in strict_reserved_words: - non_strict_use({"id": id}, None) + non_strict_use({"id": reserved_word}, None) diff --git a/src/3rdparty/v8/test/preparser/testcfg.py b/src/3rdparty/v8/test/preparser/testcfg.py index 88c06a3..61c14c9 100644 --- a/src/3rdparty/v8/test/preparser/testcfg.py +++ b/src/3rdparty/v8/test/preparser/testcfg.py @@ -25,13 +25,109 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -import test + import os -from os.path import join, dirname, exists, isfile -import platform -import utils import re +from testrunner.local import testsuite +from testrunner.local import utils +from testrunner.objects import testcase + + +class PreparserTestSuite(testsuite.TestSuite): + def __init__(self, name, root): + super(PreparserTestSuite, self).__init__(name, root) + + def shell(self): + return "preparser" + + def _GetExpectations(self): + expects_file = join(self.root, "preparser.expectation") + expectations_map = {} + if not os.path.exists(expects_file): return expectations_map + rule_regex = re.compile("^([\w\-]+)(?::([\w\-]+))?(?::(\d+),(\d+))?$") + for line in utils.ReadLinesFrom(expects_file): + rule_match = rule_regex.match(line) + if not rule_match: continue + expects = [] + if (rule_match.group(2)): + expects += [rule_match.group(2)] + if (rule_match.group(3)): + expects += [rule_match.group(3), rule_match.group(4)] + expectations_map[rule_match.group(1)] = " ".join(expects) + return expectations_map + + def _ParsePythonTestTemplates(self, result, filename): + pathname = join(self.root, filename + ".pyt") + def Test(name, source, expectation): + source = source.replace("\n", " ") + testname = os.path.join(filename, name) + flags = ["-e", source] + if expectation: + flags += ["throws", expectation] + test = testcase.TestCase(self, testname, flags=flags) + result.append(test) + def Template(name, source): + def MkTest(replacement, expectation): + testname = name + testsource = source + for key in replacement.keys(): + testname = testname.replace("$" + key, replacement[key]); + testsource = testsource.replace("$" + key, replacement[key]); + Test(testname, testsource, expectation) + return MkTest + execfile(pathname, {"Test": Test, "Template": Template}) + + def ListTests(self, context): + expectations = self._GetExpectations() + result = [] + + # Find all .js files in this directory. + filenames = [f[:-3] for f in os.listdir(self.root) if f.endswith(".js")] + filenames.sort() + for f in filenames: + throws = expectations.get(f, None) + flags = [f + ".js"] + if throws: + flags += ["throws", throws] + test = testcase.TestCase(self, f, flags=flags) + result.append(test) + + # Find all .pyt files in this directory. + filenames = [f[:-4] for f in os.listdir(self.root) if f.endswith(".pyt")] + filenames.sort() + for f in filenames: + self._ParsePythonTestTemplates(result, f) + return result + + def GetFlagsForTestCase(self, testcase, context): + first = testcase.flags[0] + if first != "-e": + testcase.flags[0] = os.path.join(self.root, first) + return testcase.flags + + def GetSourceForTest(self, testcase): + if testcase.flags[0] == "-e": + return testcase.flags[1] + with open(testcase.flags[0]) as f: + return f.read() + + def VariantFlags(self): + return [[]]; + + +def GetSuite(name, root): + return PreparserTestSuite(name, root) + + +# Deprecated definitions below. +# TODO(jkummerow): Remove when SCons is no longer supported. + + +from os.path import join, exists, isfile +import test + + class PreparserTestCase(test.TestCase): def __init__(self, root, path, executable, mode, throws, context, source): @@ -50,7 +146,7 @@ class PreparserTestCase(test.TestCase): def HasSource(self): return self.source is not None - def GetSource(): + def GetSource(self): return self.source def BuildCommand(self, path): |