Commit 57ef4f4f authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[testing] Convert some "preparser" tests into "message".

This converts existing "preparser" tests that expect a certain exception
message to be produced into "message" tests. Thereby we get much better
coverage because the former test suite degraded by now to just check
whether each test case threw or not, the exception message was not being
checked at all.

This also deprecates the ability of "preparser" to specify that single
test cases based on JS files are expected to throw, "messages" is far
superior, use that test suite instead.

R=machenbach@chromium.org
TEST=message,preparser

Review URL: https://codereview.chromium.org/1784013003

Cr-Commit-Position: refs/heads/master@{#34713}
parent 7217fcc0
......@@ -29,6 +29,10 @@
[ALWAYS, {
# All tests in the bug directory are expected to fail.
'bugs/*': [FAIL],
# We don't parse RegExps at scanning time, so we can't fail on octal
# escapes (we need to parse to distinguish octal escapes from valid
# back-references).
'strict-octal-regexp': [SKIP],
}], # ALWAYS
['ignition == True', {
# TODO(4680): Some source positions are off with Ignition.
......
*%(basename)s:32: SyntaxError: Octal literals are not allowed in strict mode.
var x = 012;
^^^
SyntaxError: Octal literals are not allowed in strict mode.
*%(basename)s:32: SyntaxError: Octal literals are not allowed in strict mode.
var x = "hello\040world";
^^
SyntaxError: Octal literals are not allowed in strict mode.
*%(basename)s:33: SyntaxError: Octal literals are not allowed in strict mode.
"use\040strict";
^^
SyntaxError: Octal literals are not allowed in strict mode.
*%(basename)s:32: SyntaxError: Octal literals are not allowed in strict mode.
"use\040strict";
^^
SyntaxError: Octal literals are not allowed in strict mode.
*%(basename)s:32: SyntaxError: Strict mode code may not include a with statement
with ({}) {}
^^^^
SyntaxError: Strict mode code may not include a with statement
# Expectations for .js preparser tests.
# Only mentions tests that throw SyntaxError, and optionally specifies
# the message and location expected in the exception.
# Format:
# testname[:message[:beg_pos,end_pos]]
strict-octal-number:strict_octal_literal
strict-octal-string:strict_octal_literal
strict-octal-regexp:strict_octal_literal
strict-octal-use-strict-after:strict_octal_literal
strict-octal-use-strict-before:strict_octal_literal
strict-const:strict_const
strict-with:strict_mode_with
......@@ -29,16 +29,5 @@
[ALWAYS, {
# TODO(mstarzinger): This script parses but throws a TypeError when run.
'non-alphanum': [FAIL],
# We don't parse RegExps at scanning time, so we can't fail on octal
# escapes (we need to parse to distinguish octal escapes from valid
# back-references).
'strict-octal-regexp': [FAIL],
}], # ALWAYS
['arch == android_arm or 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],
}], # 'arch == android_arm or arch == android_ia32'
]
......@@ -45,22 +45,6 @@ class PreparserTestSuite(testsuite.TestSuite):
def shell(self):
return "d8"
def _GetExpectations(self):
expects_file = os.path.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 = os.path.join(self.root, filename + ".pyt")
def Test(name, source, expectation, extra_flags=[]):
......@@ -84,17 +68,13 @@ class PreparserTestSuite(testsuite.TestSuite):
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"]
test = testcase.TestCase(self, f, flags=flags)
result.append(test)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment