OLD | NEW |
| (Empty) |
1 # Copyright 2008 the V8 project authors. All rights reserved. | |
2 # Redistribution and use in source and binary forms, with or without | |
3 # modification, are permitted provided that the following conditions are | |
4 # met: | |
5 # | |
6 # * Redistributions of source code must retain the above copyright | |
7 # notice, this list of conditions and the following disclaimer. | |
8 # * Redistributions in binary form must reproduce the above | |
9 # copyright notice, this list of conditions and the following | |
10 # disclaimer in the documentation and/or other materials provided | |
11 # with the distribution. | |
12 # * Neither the name of Google Inc. nor the names of its | |
13 # contributors may be used to endorse or promote products derived | |
14 # from this software without specific prior written permission. | |
15 # | |
16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
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. | |
27 | |
28 | |
29 import test | |
30 import os | |
31 from os.path import join, exists | |
32 | |
33 | |
34 def GetSuite(name, root): | |
35 # Not implemented. | |
36 return None | |
37 | |
38 | |
39 HARNESS_FILES = ['sth.js'] | |
40 | |
41 | |
42 class ES5ConformTestCase(test.TestCase): | |
43 | |
44 def __init__(self, filename, path, context, root, mode, framework): | |
45 super(ES5ConformTestCase, self).__init__(context, path, mode) | |
46 self.filename = filename | |
47 self.framework = framework | |
48 self.root = root | |
49 | |
50 def IsNegative(self): | |
51 return self.filename.endswith('-n.js') | |
52 | |
53 def GetLabel(self): | |
54 return "%s es5conform %s" % (self.mode, self.GetName()) | |
55 | |
56 def IsFailureOutput(self, output): | |
57 if output.exit_code != 0: | |
58 return True | |
59 return 'FAILED!' in output.stdout | |
60 | |
61 def GetCommand(self): | |
62 result = self.context.GetVmCommand(self, self.mode) | |
63 result += ['-e', 'var window = this'] | |
64 result += self.framework | |
65 result.append(self.filename) | |
66 result += ['-e', 'ES5Harness.startTesting()'] | |
67 return result | |
68 | |
69 def GetName(self): | |
70 return self.path[-1] | |
71 | |
72 def GetSource(self): | |
73 return open(self.filename).read() | |
74 | |
75 | |
76 class ES5ConformTestConfiguration(test.TestConfiguration): | |
77 | |
78 def __init__(self, context, root): | |
79 super(ES5ConformTestConfiguration, self).__init__(context, root) | |
80 | |
81 def ListTests(self, current_path, path, mode, variant_flags): | |
82 tests = [] | |
83 current_root = join(self.root, 'data', 'TestCases') | |
84 harness = [] | |
85 harness += [join(self.root, 'data', 'SimpleTestHarness', f) for f in HARNESS
_FILES] | |
86 harness += [join(self.root, 'harness-adapt.js')] | |
87 for root, dirs, files in os.walk(current_root): | |
88 for dotted in [x for x in dirs if x.startswith('.')]: | |
89 dirs.remove(dotted) | |
90 dirs.sort() | |
91 root_path = root[len(self.root):].split(os.path.sep) | |
92 root_path = current_path + [x for x in root_path if x] | |
93 files.sort() | |
94 for file in files: | |
95 if file.endswith('.js'): | |
96 full_path = root_path + [file[:-3]] | |
97 full_path = [x for x in full_path if not (x in ['data', 'TestCases'])] | |
98 if self.Contains(path, full_path): | |
99 test = ES5ConformTestCase(join(root, file), full_path, self.context, | |
100 self.root, mode, harness) | |
101 tests.append(test) | |
102 return tests | |
103 | |
104 def GetBuildRequirements(self): | |
105 return ['d8'] | |
106 | |
107 def GetTestStatus(self, sections, defs): | |
108 status_file = join(self.root, 'es5conform.status') | |
109 if exists(status_file): | |
110 test.ReadConfigurationInto(status_file, sections, defs) | |
111 | |
112 | |
113 def GetConfiguration(context, root): | |
114 return ES5ConformTestConfiguration(context, root) | |
OLD | NEW |