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 15 matching lines...) Expand all Loading... |
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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 ENV_PATTERN = re.compile(r"//\s+Environment Variables:(.*)") |
36 SELF_SCRIPT_PATTERN = re.compile(r"//\s+Env: TEST_FILE_NAME") | 37 SELF_SCRIPT_PATTERN = re.compile(r"//\s+Env: TEST_FILE_NAME") |
37 MODULE_PATTERN = re.compile(r"^// MODULE$", flags=re.MULTILINE) | 38 MODULE_PATTERN = re.compile(r"^// MODULE$", flags=re.MULTILINE) |
38 NO_HARNESS_PATTERN = re.compile(r"^// NO HARNESS$", flags=re.MULTILINE) | 39 NO_HARNESS_PATTERN = re.compile(r"^// NO HARNESS$", flags=re.MULTILINE) |
39 | 40 |
40 | 41 |
41 class MjsunitTestSuite(testsuite.TestSuite): | 42 class MjsunitTestSuite(testsuite.TestSuite): |
42 | 43 |
43 def __init__(self, name, root): | 44 def __init__(self, name, root): |
44 super(MjsunitTestSuite, self).__init__(name, root) | 45 super(MjsunitTestSuite, self).__init__(name, root) |
45 | 46 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 88 |
88 if MODULE_PATTERN.search(source): | 89 if MODULE_PATTERN.search(source): |
89 files.append("--module") | 90 files.append("--module") |
90 files.append(testfilename) | 91 files.append(testfilename) |
91 | 92 |
92 flags += files | 93 flags += files |
93 if context.isolates: | 94 if context.isolates: |
94 flags.append("--isolate") | 95 flags.append("--isolate") |
95 flags += files | 96 flags += files |
96 | 97 |
| 98 env_match = ENV_PATTERN.search(source) |
| 99 if env_match: |
| 100 for env_pair in env_match.group(1).strip().split(): |
| 101 var, value = env_pair.split('=') |
| 102 testcase.env[var] = value |
| 103 |
97 return testcase.flags + flags | 104 return testcase.flags + flags |
98 | 105 |
99 def GetSourceForTest(self, testcase): | 106 def GetSourceForTest(self, testcase): |
100 filename = os.path.join(self.root, testcase.path + self.suffix()) | 107 filename = os.path.join(self.root, testcase.path + self.suffix()) |
101 with open(filename) as f: | 108 with open(filename) as f: |
102 return f.read() | 109 return f.read() |
103 | 110 |
104 | 111 |
105 def GetSuite(name, root): | 112 def GetSuite(name, root): |
106 return MjsunitTestSuite(name, root) | 113 return MjsunitTestSuite(name, root) |
OLD | NEW |