diff options
Diffstat (limited to 'src/3rdparty/v8/test/mjsunit/testcfg.py')
-rw-r--r-- | src/3rdparty/v8/test/mjsunit/testcfg.py | 82 |
1 files changed, 76 insertions, 6 deletions
diff --git a/src/3rdparty/v8/test/mjsunit/testcfg.py b/src/3rdparty/v8/test/mjsunit/testcfg.py index 87ed4fa..c8b972c 100644 --- a/src/3rdparty/v8/test/mjsunit/testcfg.py +++ b/src/3rdparty/v8/test/mjsunit/testcfg.py @@ -25,17 +25,87 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -import test import os -from os.path import join, dirname, exists import re -import tempfile + +from testrunner.local import testsuite +from testrunner.objects import testcase FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") FILES_PATTERN = re.compile(r"//\s+Files:(.*)") SELF_SCRIPT_PATTERN = re.compile(r"//\s+Env: TEST_FILE_NAME") +class MjsunitTestSuite(testsuite.TestSuite): + + def __init__(self, name, root): + super(MjsunitTestSuite, self).__init__(name, root) + + def ListTests(self, context): + tests = [] + for dirname, dirs, files in os.walk(self.root): + for dotted in [x for x in dirs if x.startswith('.')]: + dirs.remove(dotted) + dirs.sort() + files.sort() + for filename in files: + if filename.endswith(".js") and filename != "mjsunit.js": + testname = join(dirname[len(self.root) + 1:], filename[:-3]) + test = testcase.TestCase(self, testname) + tests.append(test) + return tests + + def GetFlagsForTestCase(self, testcase, context): + source = self.GetSourceForTest(testcase) + flags = [] + context.mode_flags + flags_match = re.findall(FLAGS_PATTERN, source) + for match in flags_match: + flags += match.strip().split() + + files_list = [] # List of file names to append to command arguments. + files_match = FILES_PATTERN.search(source); + # Accept several lines of 'Files:'. + while True: + if files_match: + files_list += files_match.group(1).strip().split() + files_match = FILES_PATTERN.search(source, files_match.end()) + else: + break + files = [ os.path.normpath(os.path.join(self.root, '..', '..', f)) + for f in files_list ] + testfilename = os.path.join(self.root, testcase.path + self.suffix()) + if SELF_SCRIPT_PATTERN.search(source): + env = ["-e", "TEST_FILE_NAME=\"%s\"" % testfilename] + files = env + files + files.append(os.path.join(self.root, "mjsunit.js")) + files.append(testfilename) + + flags += files + if context.isolates: + flags.append("--isolate") + flags += files + + return testcase.flags + flags + + def GetSourceForTest(self, testcase): + filename = os.path.join(self.root, testcase.path + self.suffix()) + with open(filename) as f: + return f.read() + + +def GetSuite(name, root): + return MjsunitTestSuite(name, root) + + +# Deprecated definitions below. +# TODO(jkummerow): Remove when SCons is no longer supported. + + +from os.path import dirname, exists, join, normpath +import tempfile +import test + + class MjsunitTestCase(test.TestCase): def __init__(self, path, file, mode, context, config, isolates): @@ -56,9 +126,9 @@ class MjsunitTestCase(test.TestCase): def GetVmCommand(self, source): result = self.config.context.GetVmCommand(self, self.mode) - flags_match = FLAGS_PATTERN.search(source) - if flags_match: - result += flags_match.group(1).strip().split() + flags_match = re.findall(FLAGS_PATTERN, source); + for match in flags_match: + result += match.strip().split() return result def GetVmArguments(self, source): |