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 16 matching lines...) Expand all Loading... |
27 | 27 |
28 import os | 28 import os |
29 import re | 29 import re |
30 | 30 |
31 from testrunner.local import testsuite | 31 from testrunner.local import testsuite |
32 from testrunner.objects import testcase | 32 from testrunner.objects import testcase |
33 | 33 |
34 FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") | 34 FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") |
35 FILES_PATTERN = re.compile(r"//\s+Files:(.*)") | 35 FILES_PATTERN = re.compile(r"//\s+Files:(.*)") |
36 SELF_SCRIPT_PATTERN = re.compile(r"//\s+Env: TEST_FILE_NAME") | 36 SELF_SCRIPT_PATTERN = re.compile(r"//\s+Env: TEST_FILE_NAME") |
| 37 MODULE_PATTERN = re.compile(r"^// MODULE$", flags=re.MULTILINE) |
37 | 38 |
38 | 39 |
39 class MjsunitTestSuite(testsuite.TestSuite): | 40 class MjsunitTestSuite(testsuite.TestSuite): |
40 | 41 |
41 def __init__(self, name, root): | 42 def __init__(self, name, root): |
42 super(MjsunitTestSuite, self).__init__(name, root) | 43 super(MjsunitTestSuite, self).__init__(name, root) |
43 | 44 |
44 def ListTests(self, context): | 45 def ListTests(self, context): |
45 tests = [] | 46 tests = [] |
46 for dirname, dirs, files in os.walk(self.root): | 47 for dirname, dirs, files in os.walk(self.root): |
(...skipping 26 matching lines...) Expand all Loading... |
73 break | 74 break |
74 files = [ os.path.normpath(os.path.join(self.root, '..', '..', f)) | 75 files = [ os.path.normpath(os.path.join(self.root, '..', '..', f)) |
75 for f in files_list ] | 76 for f in files_list ] |
76 testfilename = os.path.join(self.root, testcase.path + self.suffix()) | 77 testfilename = os.path.join(self.root, testcase.path + self.suffix()) |
77 if SELF_SCRIPT_PATTERN.search(source): | 78 if SELF_SCRIPT_PATTERN.search(source): |
78 env = ["-e", "TEST_FILE_NAME=\"%s\"" % testfilename.replace("\\", "\\\\")] | 79 env = ["-e", "TEST_FILE_NAME=\"%s\"" % testfilename.replace("\\", "\\\\")] |
79 files = env + files | 80 files = env + files |
80 | 81 |
81 if not context.no_harness: | 82 if not context.no_harness: |
82 files.append(os.path.join(self.root, "mjsunit.js")) | 83 files.append(os.path.join(self.root, "mjsunit.js")) |
| 84 |
| 85 if MODULE_PATTERN.search(source): |
| 86 files.append("--module") |
83 files.append(testfilename) | 87 files.append(testfilename) |
84 | 88 |
85 flags += files | 89 flags += files |
86 if context.isolates: | 90 if context.isolates: |
87 flags.append("--isolate") | 91 flags.append("--isolate") |
88 flags += files | 92 flags += files |
89 | 93 |
90 return testcase.flags + flags | 94 return testcase.flags + flags |
91 | 95 |
92 def GetSourceForTest(self, testcase): | 96 def GetSourceForTest(self, testcase): |
93 filename = os.path.join(self.root, testcase.path + self.suffix()) | 97 filename = os.path.join(self.root, testcase.path + self.suffix()) |
94 with open(filename) as f: | 98 with open(filename) as f: |
95 return f.read() | 99 return f.read() |
96 | 100 |
97 | 101 |
98 def GetSuite(name, root): | 102 def GetSuite(name, root): |
99 return MjsunitTestSuite(name, root) | 103 return MjsunitTestSuite(name, root) |
OLD | NEW |