| OLD | NEW |
| 1 # Copyright 2008 the V8 project authors. All rights reserved. | 1 # Copyright 2008 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 for i in xrange(len(testfilepath)): | 97 for i in xrange(len(testfilepath)): |
| 98 script = os.path.join(self.testroot, | 98 script = os.path.join(self.testroot, |
| 99 reduce(os.path.join, testfilepath[:i], ""), | 99 reduce(os.path.join, testfilepath[:i], ""), |
| 100 "shell.js") | 100 "shell.js") |
| 101 if os.path.exists(script): | 101 if os.path.exists(script): |
| 102 result.append(script) | 102 result.append(script) |
| 103 result.append(os.path.join(self.testroot, testfilename)) | 103 result.append(os.path.join(self.testroot, testfilename)) |
| 104 return testcase.flags + result | 104 return testcase.flags + result |
| 105 | 105 |
| 106 def GetSourceForTest(self, testcase): | 106 def GetSourceForTest(self, testcase): |
| 107 filename = join(self.testroot, testcase.path + ".js") | 107 filename = os.path.join(self.testroot, testcase.path + ".js") |
| 108 with open(filename) as f: | 108 with open(filename) as f: |
| 109 return f.read() | 109 return f.read() |
| 110 | 110 |
| 111 def IsNegativeTest(self, testcase): | 111 def IsNegativeTest(self, testcase): |
| 112 return testcase.path.endswith("-n") | 112 return testcase.path.endswith("-n") |
| 113 | 113 |
| 114 def IsFailureOutput(self, output, testpath): | 114 def IsFailureOutput(self, output, testpath): |
| 115 if output.exit_code != 0: | 115 if output.exit_code != 0: |
| 116 return True | 116 return True |
| 117 return "FAILED!" in output.stdout | 117 return "FAILED!" in output.stdout |
| (...skipping 25 matching lines...) Expand all Loading... |
| 143 os.chdir(old_cwd) | 143 os.chdir(old_cwd) |
| 144 return | 144 return |
| 145 | 145 |
| 146 # No cached copy. Check out via CVS, and pack as .tar.gz for later use. | 146 # No cached copy. Check out via CVS, and pack as .tar.gz for later use. |
| 147 command = ("cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot" | 147 command = ("cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot" |
| 148 " co -D %s mozilla/js/tests" % MOZILLA_VERSION) | 148 " co -D %s mozilla/js/tests" % MOZILLA_VERSION) |
| 149 code = subprocess.call(command, shell=True) | 149 code = subprocess.call(command, shell=True) |
| 150 if code != 0: | 150 if code != 0: |
| 151 os.chdir(old_cwd) | 151 os.chdir(old_cwd) |
| 152 raise Exception("Error checking out Mozilla test suite!") | 152 raise Exception("Error checking out Mozilla test suite!") |
| 153 os.rename(join("mozilla", "js", "tests"), directory_name) | 153 os.rename(os.path.join("mozilla", "js", "tests"), directory_name) |
| 154 shutil.rmtree("mozilla") | 154 shutil.rmtree("mozilla") |
| 155 with tarfile.open(archive_file, "w:gz") as tar: | 155 with tarfile.open(archive_file, "w:gz") as tar: |
| 156 tar.add("data") | 156 tar.add("data") |
| 157 with open(versionfile, "w") as f: | 157 with open(versionfile, "w") as f: |
| 158 f.write(MOZILLA_VERSION) | 158 f.write(MOZILLA_VERSION) |
| 159 os.chdir(old_cwd) | 159 os.chdir(old_cwd) |
| 160 | 160 |
| 161 | 161 |
| 162 def GetSuite(name, root): | 162 def GetSuite(name, root): |
| 163 return MozillaTestSuite(name, root) | 163 return MozillaTestSuite(name, root) |
| 164 | |
| 165 | |
| 166 # Deprecated definitions below. | |
| 167 # TODO(jkummerow): Remove when SCons is no longer supported. | |
| 168 | |
| 169 | |
| 170 from os.path import exists | |
| 171 from os.path import join | |
| 172 import test | |
| 173 | |
| 174 | |
| 175 class MozillaTestCase(test.TestCase): | |
| 176 | |
| 177 def __init__(self, filename, path, context, root, mode, framework): | |
| 178 super(MozillaTestCase, self).__init__(context, path, mode) | |
| 179 self.filename = filename | |
| 180 self.framework = framework | |
| 181 self.root = root | |
| 182 | |
| 183 def IsNegative(self): | |
| 184 return self.filename.endswith('-n.js') | |
| 185 | |
| 186 def GetLabel(self): | |
| 187 return "%s mozilla %s" % (self.mode, self.GetName()) | |
| 188 | |
| 189 def IsFailureOutput(self, output): | |
| 190 if output.exit_code != 0: | |
| 191 return True | |
| 192 return 'FAILED!' in output.stdout | |
| 193 | |
| 194 def GetCommand(self): | |
| 195 result = self.context.GetVmCommand(self, self.mode) + \ | |
| 196 [ '--expose-gc', join(self.root, 'mozilla-shell-emulation.js') ] | |
| 197 result += [ '--es5_readonly' ] # Temporary hack until we can remove flag | |
| 198 result += self.framework | |
| 199 result.append(self.filename) | |
| 200 return result | |
| 201 | |
| 202 def GetName(self): | |
| 203 return self.path[-1] | |
| 204 | |
| 205 def GetSource(self): | |
| 206 return open(self.filename).read() | |
| 207 | |
| 208 | |
| 209 class MozillaTestConfiguration(test.TestConfiguration): | |
| 210 | |
| 211 def __init__(self, context, root): | |
| 212 super(MozillaTestConfiguration, self).__init__(context, root) | |
| 213 | |
| 214 def ListTests(self, current_path, path, mode, variant_flags): | |
| 215 tests = [] | |
| 216 for test_dir in TEST_DIRS: | |
| 217 current_root = join(self.root, 'data', test_dir) | |
| 218 for root, dirs, files in os.walk(current_root): | |
| 219 for dotted in [x for x in dirs if x.startswith('.')]: | |
| 220 dirs.remove(dotted) | |
| 221 for excluded in EXCLUDED: | |
| 222 if excluded in dirs: | |
| 223 dirs.remove(excluded) | |
| 224 dirs.sort() | |
| 225 root_path = root[len(self.root):].split(os.path.sep) | |
| 226 root_path = current_path + [x for x in root_path if x] | |
| 227 framework = [] | |
| 228 for i in xrange(len(root_path)): | |
| 229 if i == 0: dir = root_path[1:] | |
| 230 else: dir = root_path[1:-i] | |
| 231 script = join(self.root, reduce(join, dir, ''), 'shell.js') | |
| 232 if exists(script): | |
| 233 framework.append(script) | |
| 234 framework.reverse() | |
| 235 files.sort() | |
| 236 for file in files: | |
| 237 if (not file in FRAMEWORK) and file.endswith('.js'): | |
| 238 full_path = root_path + [file[:-3]] | |
| 239 full_path = [x for x in full_path if x != 'data'] | |
| 240 if self.Contains(path, full_path): | |
| 241 test = MozillaTestCase(join(root, file), full_path, self.context, | |
| 242 self.root, mode, framework) | |
| 243 tests.append(test) | |
| 244 return tests | |
| 245 | |
| 246 def GetBuildRequirements(self): | |
| 247 return ['d8'] | |
| 248 | |
| 249 def GetTestStatus(self, sections, defs): | |
| 250 status_file = join(self.root, 'mozilla.status') | |
| 251 if exists(status_file): | |
| 252 test.ReadConfigurationInto(status_file, sections, defs) | |
| 253 | |
| 254 | |
| 255 def GetConfiguration(context, root): | |
| 256 return MozillaTestConfiguration(context, root) | |
| OLD | NEW |