OLD | NEW |
---|---|
(Empty) | |
1 # Copyright 2011 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 TEST_262_HARNESS = ['sta.js'] | |
35 | |
36 | |
37 class Test262TestCase(test.TestCase): | |
38 | |
39 def __init__(self, filename, path, context, root, mode, framework): | |
40 super(Test262TestCase, self).__init__(context, path, mode) | |
41 self.filename = filename | |
42 self.framework = framework | |
43 self.root = root | |
44 | |
45 def IsNegative(self): | |
46 return self.filename.endswith('-n.js') | |
47 | |
48 def GetLabel(self): | |
49 return "%s test262 %s %s" % (self.mode, self.GetGroup(), self.GetName()) | |
50 | |
51 def IsFailureOutput(self, output): | |
52 if output.exit_code != 0: | |
53 return True | |
54 return 'FAILED!' in output.stdout | |
55 | |
56 def GetCommand(self): | |
57 result = self.context.GetVmCommand(self, self.mode) | |
58 result += ['-e', 'var window = this'] | |
59 result += self.framework | |
60 result.append(self.filename) | |
61 return result | |
62 | |
63 def GetName(self): | |
64 return self.path[-1] | |
65 | |
66 def GetGroup(self): | |
67 return self.path[0] | |
68 | |
69 def GetSource(self): | |
70 return open(self.filename).read() | |
71 | |
72 | |
73 class Test262TestConfiguration(test.TestConfiguration): | |
74 | |
75 def __init__(self, context, root): | |
76 super(Test262TestConfiguration, self).__init__(context, root) | |
77 | |
78 def AddIETestCenter(self, tests, current_path, path, mode): | |
79 current_root = join(self.root, 'data', 'test', 'suite', 'ietestcenter') | |
80 harness = [join(self.root, 'jquery.js')] | |
81 harness += [join(self.root, 'data', 'test', 'harness', f) for f in TEST_262_ HARNESS] | |
Rico
2011/03/21 10:23:53
Long line
Martin Maly
2011/03/28 20:04:21
Done.
| |
82 harness += [join(self.root, 'harness-adapt.js')] | |
83 for root, dirs, files in os.walk(current_root): | |
84 for dotted in [x for x in dirs if x.startswith('.')]: | |
85 dirs.remove(dotted) | |
86 dirs.sort() | |
87 root_path = root[len(self.root):].split(os.path.sep) | |
88 root_path = current_path + [x for x in root_path if x] | |
89 files.sort() | |
90 for file in files: | |
91 if file.endswith('.js'): | |
92 if self.Contains(path, root_path): | |
93 test_path = ['ietestcenter', file[:-3]] | |
94 test = Test262TestCase(join(root, file), test_path, self.context, | |
95 self.root, mode, harness) | |
96 tests.append(test) | |
97 | |
98 def AddSputnikConvertedTests(self, tests, current_path, path, mode): | |
99 current_root = join(self.root, 'data', 'test', 'suite', 'sputnik_converted') | |
100 harness = [join(self.root, 'jquery.js')] | |
101 harness += [join(self.root, 'data', 'test', 'harness', f) for f in TEST_262_ HARNESS] | |
Rico
2011/03/21 10:23:53
Long line
Martin Maly
2011/03/28 20:04:21
Done.
| |
102 harness += [join(self.root, 'harness-adapt.js')] | |
103 for root, dirs, files in os.walk(current_root): | |
104 for dotted in [x for x in dirs if x.startswith('.')]: | |
105 dirs.remove(dotted) | |
106 dirs.sort() | |
107 root_path = root[len(self.root):].split(os.path.sep) | |
108 root_path = current_path + [x for x in root_path if x] | |
109 files.sort() | |
110 for file in files: | |
111 if file.endswith('.js'): | |
112 if self.Contains(path, root_path): | |
113 test_path = ['sputnik_converted', file[:-3]] | |
114 test = Test262TestCase(join(root, file), test_path, self.context, | |
115 self.root, mode, harness) | |
116 tests.append(test) | |
117 | |
118 def AddSputnikTests(self, tests, current_path, path, mode): | |
119 # To be implemented | |
120 pass | |
121 | |
122 def ListTests(self, current_path, path, mode): | |
123 tests = [] | |
124 self.AddIETestCenter(tests, current_path, path, mode) | |
125 self.AddSputnikConvertedTests(tests, current_path, path, mode) | |
126 self.AddSputnikTests(tests, current_path, path, mode) | |
127 return tests | |
128 | |
129 def GetBuildRequirements(self): | |
130 return ['sample', 'sample=shell'] | |
131 | |
132 def GetTestStatus(self, sections, defs): | |
133 status_file = join(self.root, 'test262.status') | |
134 if exists(status_file): | |
135 test.ReadConfigurationInto(status_file, sections, defs) | |
136 | |
137 | |
138 def GetConfiguration(context, root): | |
139 return Test262TestConfiguration(context, root) | |
OLD | NEW |