blob: 587781d11f24abf747d7948268c66832e924e32c [file] [log] [blame]
Steve Blocka7e24c12009-10-30 11:49:00 +00001# 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
29import test
30import os
31from os.path import join, exists
32
33
34EXCLUDED = ['CVS']
35
36
37FRAMEWORK = """
38 browser.js
39 shell.js
40 jsref.js
41 template.js
42""".split()
43
44
45TEST_DIRS = """
46 ecma
47 ecma_2
48 ecma_3
49 js1_1
50 js1_2
51 js1_3
52 js1_4
53 js1_5
54""".split()
55
56
57class MozillaTestCase(test.TestCase):
58
59 def __init__(self, filename, path, context, root, mode, framework):
Kristian Monsen80d68ea2010-09-08 11:05:35 +010060 super(MozillaTestCase, self).__init__(context, path, mode)
Steve Blocka7e24c12009-10-30 11:49:00 +000061 self.filename = filename
Steve Blocka7e24c12009-10-30 11:49:00 +000062 self.framework = framework
63 self.root = root
64
65 def IsNegative(self):
66 return self.filename.endswith('-n.js')
67
68 def GetLabel(self):
69 return "%s mozilla %s" % (self.mode, self.GetName())
70
71 def IsFailureOutput(self, output):
72 if output.exit_code != 0:
73 return True
74 return 'FAILED!' in output.stdout
75
76 def GetCommand(self):
Kristian Monsen80d68ea2010-09-08 11:05:35 +010077 result = self.context.GetVmCommand(self, self.mode) + \
78 [ '--expose-gc', join(self.root, 'mozilla-shell-emulation.js') ]
Steve Blocka7e24c12009-10-30 11:49:00 +000079 result += self.framework
80 result.append(self.filename)
81 return result
82
83 def GetName(self):
84 return self.path[-1]
85
86 def GetSource(self):
87 return open(self.filename).read()
88
89
90class MozillaTestConfiguration(test.TestConfiguration):
91
92 def __init__(self, context, root):
93 super(MozillaTestConfiguration, self).__init__(context, root)
94
Steve Block44f0eee2011-05-26 01:26:41 +010095 def ListTests(self, current_path, path, mode, variant_flags):
Steve Blocka7e24c12009-10-30 11:49:00 +000096 tests = []
97 for test_dir in TEST_DIRS:
98 current_root = join(self.root, 'data', test_dir)
99 for root, dirs, files in os.walk(current_root):
100 for dotted in [x for x in dirs if x.startswith('.')]:
101 dirs.remove(dotted)
102 for excluded in EXCLUDED:
103 if excluded in dirs:
104 dirs.remove(excluded)
Steve Blockd0582a62009-12-15 09:54:21 +0000105 dirs.sort()
Steve Blocka7e24c12009-10-30 11:49:00 +0000106 root_path = root[len(self.root):].split(os.path.sep)
107 root_path = current_path + [x for x in root_path if x]
108 framework = []
109 for i in xrange(len(root_path)):
110 if i == 0: dir = root_path[1:]
111 else: dir = root_path[1:-i]
112 script = join(self.root, reduce(join, dir, ''), 'shell.js')
113 if exists(script):
114 framework.append(script)
115 framework.reverse()
Steve Blockd0582a62009-12-15 09:54:21 +0000116 files.sort()
Steve Blocka7e24c12009-10-30 11:49:00 +0000117 for file in files:
118 if (not file in FRAMEWORK) and file.endswith('.js'):
119 full_path = root_path + [file[:-3]]
120 full_path = [x for x in full_path if x != 'data']
121 if self.Contains(path, full_path):
122 test = MozillaTestCase(join(root, file), full_path, self.context,
123 self.root, mode, framework)
124 tests.append(test)
125 return tests
126
127 def GetBuildRequirements(self):
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000128 return ['d8']
Steve Blocka7e24c12009-10-30 11:49:00 +0000129
130 def GetTestStatus(self, sections, defs):
131 status_file = join(self.root, 'mozilla.status')
132 if exists(status_file):
133 test.ReadConfigurationInto(status_file, sections, defs)
134
135
136def GetConfiguration(context, root):
137 return MozillaTestConfiguration(context, root)