Skip to content

Commit 975d6e2

Browse files
author
jkummerow@chromium.org
committed
First commit of new tools/run-tests.py
Review URL: https://codereview.chromium.org/10919265 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12583 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
1 parent 26721b7 commit 975d6e2

47 files changed

Lines changed: 5075 additions & 51 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,19 @@ shell_g
2727
/build/Release
2828
/obj/
2929
/out/
30+
/test/cctest/cctest.status2
3031
/test/es5conform/data
32+
/test/messages/messages.status2
33+
/test/mjsunit/mjsunit.status2
34+
/test/mozilla/CHECKED_OUT_VERSION
3135
/test/mozilla/data
36+
/test/mozilla/downloaded_*
37+
/test/mozilla/mozilla.status2
38+
/test/preparser/preparser.status2
3239
/test/sputnik/sputniktests
3340
/test/test262/data
41+
/test/test262/test262-*
42+
/test/test262/test262.status2
3443
/third_party
3544
/tools/jsfunfuzz
3645
/tools/jsfunfuzz.zip

test/benchmarks/testcfg.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
import os
3131
from os.path import join, split
3232

33+
def GetSuite(name, root):
34+
# Not implemented.
35+
return None
36+
37+
3338
def IsNumber(string):
3439
try:
3540
float(string)

test/cctest/testcfg.py

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,66 @@
2525
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2626
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2727

28-
import test
2928
import os
30-
from os.path import join, dirname, exists
31-
import platform
32-
import utils
29+
import shutil
30+
31+
from testrunner.local import commands
32+
from testrunner.local import testsuite
33+
from testrunner.local import utils
34+
from testrunner.objects import testcase
35+
36+
37+
class CcTestSuite(testsuite.TestSuite):
38+
39+
def __init__(self, name, root):
40+
super(CcTestSuite, self).__init__(name, root)
41+
self.serdes_dir = normpath(join(root, "..", "..", "out", ".serdes"))
42+
if exists(self.serdes_dir):
43+
shutil.rmtree(self.serdes_dir, True)
44+
os.makedirs(self.serdes_dir)
45+
46+
def ListTests(self, context):
47+
shell = join(context.shell_dir, self.shell())
48+
if utils.IsWindows():
49+
shell += '.exe'
50+
output = commands.Execute([shell, '--list'])
51+
if output.exit_code != 0:
52+
print output.stdout
53+
print output.stderr
54+
return []
55+
tests = []
56+
for test_desc in output.stdout.strip().split():
57+
raw_test, dependency = test_desc.split('<')
58+
if dependency != '':
59+
dependency = raw_test.split('/')[0] + '/' + dependency
60+
else:
61+
dependency = None
62+
test = testcase.TestCase(self, raw_test, dependency=dependency)
63+
tests.append(test)
64+
tests.sort()
65+
return tests
66+
67+
def GetFlagsForTestCase(self, testcase, context):
68+
testname = testcase.path.split(os.path.sep)[-1]
69+
serialization_file = join(self.serdes_dir, "serdes_" + testname)
70+
serialization_file += ''.join(testcase.flags).replace('-', '_')
71+
return (testcase.flags + [testcase.path] + context.mode_flags +
72+
["--testing_serialization_file=" + serialization_file])
73+
74+
def shell(self):
75+
return "cctest"
76+
77+
78+
def GetSuite(name, root):
79+
return CcTestSuite(name, root)
80+
81+
82+
# Deprecated definitions below.
83+
# TODO(jkummerow): Remove when SCons is no longer supported.
84+
85+
86+
from os.path import exists, join, normpath
87+
import test
3388

3489

3590
class CcTestCase(test.TestCase):

test/es5conform/testcfg.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
from os.path import join, exists
3232

3333

34+
def GetSuite(name, root):
35+
# Not implemented.
36+
return None
37+
38+
3439
HARNESS_FILES = ['sth.js']
3540

3641

test/message/testcfg.py

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,93 @@
2525
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2626
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2727

28-
import test
28+
import itertools
2929
import os
30-
from os.path import join, dirname, exists, basename, isdir
3130
import re
3231

32+
from testrunner.local import testsuite
33+
from testrunner.local import utils
34+
from testrunner.objects import testcase
35+
36+
3337
FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
3438

39+
40+
class MessageTestSuite(testsuite.TestSuite):
41+
def __init__(self, name, root):
42+
super(MessageTestSuite, self).__init__(name, root)
43+
44+
def ListTests(self, context):
45+
tests = []
46+
for dirname, dirs, files in os.walk(self.root):
47+
for dotted in [x for x in dirs if x.startswith('.')]:
48+
dirs.remove(dotted)
49+
dirs.sort()
50+
files.sort()
51+
for filename in files:
52+
if filename.endswith(".js"):
53+
testname = join(dirname[len(self.root) + 1:], filename[:-3])
54+
test = testcase.TestCase(self, testname)
55+
tests.append(test)
56+
return tests
57+
58+
def GetFlagsForTestCase(self, testcase, context):
59+
source = self.GetSourceForTest(testcase)
60+
result = []
61+
flags_match = re.findall(FLAGS_PATTERN, source)
62+
for match in flags_match:
63+
result += match.strip().split()
64+
result += context.mode_flags
65+
result.append(os.path.join(self.root, testcase.path + ".js"))
66+
return testcase.flags + result
67+
68+
def GetSourceForTest(self, testcase):
69+
filename = os.path.join(self.root, testcase.path + self.suffix())
70+
with open(filename) as f:
71+
return f.read()
72+
73+
def _IgnoreLine(self, string):
74+
"""Ignore empty lines, valgrind output and Android output."""
75+
if not string: return True
76+
return (string.startswith("==") or string.startswith("**") or
77+
string.startswith("ANDROID"))
78+
79+
def IsFailureOutput(self, output, testpath):
80+
expected_path = os.path.join(self.root, testpath + ".out")
81+
expected_lines = []
82+
# Can't use utils.ReadLinesFrom() here because it strips whitespace.
83+
with open(expected_path) as f:
84+
for line in f:
85+
if line.startswith("#") or not line.strip(): continue
86+
expected_lines.append(line)
87+
raw_lines = output.stdout.splitlines()
88+
actual_lines = [ s for s in raw_lines if not self._IgnoreLine(s) ]
89+
env = { "basename": os.path.basename(testpath + ".js") }
90+
if len(expected_lines) != len(actual_lines):
91+
return True
92+
for (expected, actual) in itertools.izip(expected_lines, actual_lines):
93+
pattern = re.escape(expected.rstrip() % env)
94+
pattern = pattern.replace("\\*", ".*")
95+
pattern = "^%s$" % pattern
96+
if not re.match(pattern, actual):
97+
return True
98+
return False
99+
100+
def StripOutputForTransmit(self, testcase):
101+
pass
102+
103+
104+
def GetSuite(name, root):
105+
return MessageTestSuite(name, root)
106+
107+
108+
# Deprecated definitions below.
109+
# TODO(jkummerow): Remove when SCons is no longer supported.
110+
111+
112+
import test
113+
from os.path import join, exists, basename, isdir
114+
35115
class MessageTestCase(test.TestCase):
36116

37117
def __init__(self, path, file, expected, mode, context, config):
Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
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.
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.

test/mjsunit/testcfg.py

Lines changed: 74 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,88 @@
2525
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2626
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2727

28-
import test
2928
import os
30-
from os.path import join, dirname, exists
3129
import re
32-
import tempfile
30+
31+
from testrunner.local import testsuite
32+
from testrunner.objects import testcase
3333

3434
FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
3535
FILES_PATTERN = re.compile(r"//\s+Files:(.*)")
3636
SELF_SCRIPT_PATTERN = re.compile(r"//\s+Env: TEST_FILE_NAME")
3737

3838

39+
class MjsunitTestSuite(testsuite.TestSuite):
40+
41+
def __init__(self, name, root):
42+
super(MjsunitTestSuite, self).__init__(name, root)
43+
44+
def ListTests(self, context):
45+
tests = []
46+
for dirname, dirs, files in os.walk(self.root):
47+
for dotted in [x for x in dirs if x.startswith('.')]:
48+
dirs.remove(dotted)
49+
dirs.sort()
50+
files.sort()
51+
for filename in files:
52+
if filename.endswith(".js") and filename != "mjsunit.js":
53+
testname = join(dirname[len(self.root) + 1:], filename[:-3])
54+
test = testcase.TestCase(self, testname)
55+
tests.append(test)
56+
return tests
57+
58+
def GetFlagsForTestCase(self, testcase, context):
59+
source = self.GetSourceForTest(testcase)
60+
flags = []
61+
flags_match = re.findall(FLAGS_PATTERN, source)
62+
for match in flags_match:
63+
flags += match.strip().split()
64+
flags += context.mode_flags
65+
66+
files_list = [] # List of file names to append to command arguments.
67+
files_match = FILES_PATTERN.search(source);
68+
# Accept several lines of 'Files:'.
69+
while True:
70+
if files_match:
71+
files_list += files_match.group(1).strip().split()
72+
files_match = FILES_PATTERN.search(source, files_match.end())
73+
else:
74+
break
75+
files = [ os.path.normpath(os.path.join(self.root, '..', '..', f))
76+
for f in files_list ]
77+
testfilename = os.path.join(self.root, testcase.path + self.suffix())
78+
if SELF_SCRIPT_PATTERN.search(source):
79+
env = ["-e", "TEST_FILE_NAME=\"%s\"" % testfilename]
80+
files = env + files
81+
files.append(os.path.join(self.root, "mjsunit.js"))
82+
files.append(testfilename)
83+
84+
flags += files
85+
if context.isolates:
86+
flags.append("--isolate")
87+
flags += files
88+
89+
return testcase.flags + flags
90+
91+
def GetSourceForTest(self, testcase):
92+
filename = os.path.join(self.root, testcase.path + self.suffix())
93+
with open(filename) as f:
94+
return f.read()
95+
96+
97+
def GetSuite(name, root):
98+
return MjsunitTestSuite(name, root)
99+
100+
101+
# Deprecated definitions below.
102+
# TODO(jkummerow): Remove when SCons is no longer supported.
103+
104+
105+
from os.path import dirname, exists, join, normpath
106+
import tempfile
107+
import test
108+
109+
39110
class MjsunitTestCase(test.TestCase):
40111

41112
def __init__(self, path, file, mode, context, config, isolates):

0 commit comments

Comments
 (0)