| Index: test/preparser/testcfg.py
|
| diff --git a/test/preparser/testcfg.py b/test/preparser/testcfg.py
|
| index c78d03bc470bcc5552acc9603e23ff7610492bfa..81cafb9979b86f8e4ed9fb657ed25a12d4f1f123 100644
|
| --- a/test/preparser/testcfg.py
|
| +++ b/test/preparser/testcfg.py
|
| @@ -30,14 +30,15 @@ import os
|
| from os.path import join, dirname, exists
|
| import platform
|
| import utils
|
| -
|
| +import re
|
|
|
| class PreparserTestCase(test.TestCase):
|
|
|
| - def __init__(self, root, path, executable, mode, context):
|
| + def __init__(self, root, path, executable, mode, throws, context):
|
| super(PreparserTestCase, self).__init__(context, path, mode)
|
| self.executable = executable
|
| self.root = root
|
| + self.throws = throws
|
|
|
| def GetLabel(self):
|
| return "%s %s %s" % (self.mode, self.path[-2], self.path[-1])
|
| @@ -48,6 +49,8 @@ class PreparserTestCase(test.TestCase):
|
| def BuildCommand(self, path):
|
| testfile = join(self.root, self.GetName()) + ".js"
|
| result = [self.executable, testfile]
|
| + if (self.throws):
|
| + result += ['throws'] + self.throws
|
| return result
|
|
|
| def GetCommand(self):
|
| @@ -65,19 +68,41 @@ class PreparserTestConfiguration(test.TestConfiguration):
|
| def GetBuildRequirements(self):
|
| return ['preparser']
|
|
|
| + def GetExpectations(self):
|
| + expects_file = join(self.root, 'preparser.expectation')
|
| + map = {}
|
| + if exists(expects_file):
|
| + rule_regex = re.compile("^([\w\-]+)(?::([\w\-]+))?(?::(\d+),(\d+))?$")
|
| + for line in utils.ReadLinesFrom(expects_file):
|
| + if (line[0] == '#'): continue
|
| + rule_match = rule_regex.match(line)
|
| + if rule_match:
|
| + expects = []
|
| + if (rule_match.group(2)):
|
| + expects = expects + [rule_match.group(2)]
|
| + if (rule_match.group(3)):
|
| + expects = expects + [rule_match.group(3), rule_match.group(4)]
|
| + map[rule_match.group(1)] = expects
|
| + return map;
|
| +
|
| +
|
| def ListTests(self, current_path, path, mode, variant_flags):
|
| executable = join('obj', 'preparser', mode, 'preparser')
|
| if utils.IsWindows():
|
| executable += '.exe'
|
| executable = join(self.context.buildspace, executable)
|
| + expectations = self.GetExpectations()
|
| # Find all .js files in tests/preparser directory.
|
| filenames = [f[:-3] for f in os.listdir(self.root) if f.endswith(".js")]
|
| filenames.sort()
|
| result = []
|
| for file in filenames:
|
| + throws = None;
|
| + if (file in expectations):
|
| + throws = expectations[file]
|
| result.append(PreparserTestCase(self.root,
|
| current_path + [file], executable,
|
| - mode, self.context))
|
| + mode, throws, self.context))
|
| return result
|
|
|
| def GetTestStatus(self, sections, defs):
|
|
|