OLD | NEW |
1 # Copyright 2011 the V8 project authors. All rights reserved. | 1 # Copyright 2011 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 12 matching lines...) Expand all Loading... |
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 import test | 28 import test |
29 import os | 29 import os |
30 from os.path import join, dirname, exists | 30 from os.path import join, dirname, exists |
31 import platform | 31 import platform |
32 import utils | 32 import utils |
33 | 33 import re |
34 | 34 |
35 class PreparserTestCase(test.TestCase): | 35 class PreparserTestCase(test.TestCase): |
36 | 36 |
37 def __init__(self, root, path, executable, mode, context): | 37 def __init__(self, root, path, executable, mode, throws, context): |
38 super(PreparserTestCase, self).__init__(context, path, mode) | 38 super(PreparserTestCase, self).__init__(context, path, mode) |
39 self.executable = executable | 39 self.executable = executable |
40 self.root = root | 40 self.root = root |
| 41 self.throws = throws |
41 | 42 |
42 def GetLabel(self): | 43 def GetLabel(self): |
43 return "%s %s %s" % (self.mode, self.path[-2], self.path[-1]) | 44 return "%s %s %s" % (self.mode, self.path[-2], self.path[-1]) |
44 | 45 |
45 def GetName(self): | 46 def GetName(self): |
46 return self.path[-1] | 47 return self.path[-1] |
47 | 48 |
48 def BuildCommand(self, path): | 49 def BuildCommand(self, path): |
49 testfile = join(self.root, self.GetName()) + ".js" | 50 testfile = join(self.root, self.GetName()) + ".js" |
50 result = [self.executable, testfile] | 51 result = [self.executable, testfile] |
| 52 if (self.throws): |
| 53 result += ['throws'] + self.throws |
51 return result | 54 return result |
52 | 55 |
53 def GetCommand(self): | 56 def GetCommand(self): |
54 return self.BuildCommand(self.path) | 57 return self.BuildCommand(self.path) |
55 | 58 |
56 def Run(self): | 59 def Run(self): |
57 return test.TestCase.Run(self) | 60 return test.TestCase.Run(self) |
58 | 61 |
59 | 62 |
60 class PreparserTestConfiguration(test.TestConfiguration): | 63 class PreparserTestConfiguration(test.TestConfiguration): |
61 | 64 |
62 def __init__(self, context, root): | 65 def __init__(self, context, root): |
63 super(PreparserTestConfiguration, self).__init__(context, root) | 66 super(PreparserTestConfiguration, self).__init__(context, root) |
64 | 67 |
65 def GetBuildRequirements(self): | 68 def GetBuildRequirements(self): |
66 return ['preparser'] | 69 return ['preparser'] |
67 | 70 |
| 71 def GetExpectations(self): |
| 72 expects_file = join(self.root, 'preparser.expectation') |
| 73 map = {} |
| 74 if exists(expects_file): |
| 75 rule_regex = re.compile("^([\w\-]+)(?::([\w\-]+))?(?::(\d+),(\d+))?$") |
| 76 for line in utils.ReadLinesFrom(expects_file): |
| 77 if (line[0] == '#'): continue |
| 78 rule_match = rule_regex.match(line) |
| 79 if rule_match: |
| 80 expects = [] |
| 81 if (rule_match.group(2)): |
| 82 expects = expects + [rule_match.group(2)] |
| 83 if (rule_match.group(3)): |
| 84 expects = expects + [rule_match.group(3), rule_match.group(4)] |
| 85 map[rule_match.group(1)] = expects |
| 86 return map; |
| 87 |
| 88 |
68 def ListTests(self, current_path, path, mode, variant_flags): | 89 def ListTests(self, current_path, path, mode, variant_flags): |
69 executable = join('obj', 'preparser', mode, 'preparser') | 90 executable = join('obj', 'preparser', mode, 'preparser') |
70 if utils.IsWindows(): | 91 if utils.IsWindows(): |
71 executable += '.exe' | 92 executable += '.exe' |
72 executable = join(self.context.buildspace, executable) | 93 executable = join(self.context.buildspace, executable) |
| 94 expectations = self.GetExpectations() |
73 # Find all .js files in tests/preparser directory. | 95 # Find all .js files in tests/preparser directory. |
74 filenames = [f[:-3] for f in os.listdir(self.root) if f.endswith(".js")] | 96 filenames = [f[:-3] for f in os.listdir(self.root) if f.endswith(".js")] |
75 filenames.sort() | 97 filenames.sort() |
76 result = [] | 98 result = [] |
77 for file in filenames: | 99 for file in filenames: |
| 100 throws = None; |
| 101 if (file in expectations): |
| 102 throws = expectations[file] |
78 result.append(PreparserTestCase(self.root, | 103 result.append(PreparserTestCase(self.root, |
79 current_path + [file], executable, | 104 current_path + [file], executable, |
80 mode, self.context)) | 105 mode, throws, self.context)) |
81 return result | 106 return result |
82 | 107 |
83 def GetTestStatus(self, sections, defs): | 108 def GetTestStatus(self, sections, defs): |
84 status_file = join(self.root, 'preparser.status') | 109 status_file = join(self.root, 'preparser.status') |
85 if exists(status_file): | 110 if exists(status_file): |
86 test.ReadConfigurationInto(status_file, sections, defs) | 111 test.ReadConfigurationInto(status_file, sections, defs) |
87 | 112 |
88 | 113 |
89 def GetConfiguration(context, root): | 114 def GetConfiguration(context, root): |
90 return PreparserTestConfiguration(context, root) | 115 return PreparserTestConfiguration(context, root) |
OLD | NEW |