| 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:(.*)") | |
| 37 SELF_SCRIPT_PATTERN = re.compile(r"//\s+Env: TEST_FILE_NAME") | 36 SELF_SCRIPT_PATTERN = re.compile(r"//\s+Env: TEST_FILE_NAME") |
| 38 MODULE_PATTERN = re.compile(r"^// MODULE$", flags=re.MULTILINE) | 37 MODULE_PATTERN = re.compile(r"^// MODULE$", flags=re.MULTILINE) |
| 39 NO_HARNESS_PATTERN = re.compile(r"^// NO HARNESS$", flags=re.MULTILINE) | 38 NO_HARNESS_PATTERN = re.compile(r"^// NO HARNESS$", flags=re.MULTILINE) |
| 40 | 39 |
| 41 | 40 |
| 42 class MjsunitTestSuite(testsuite.TestSuite): | 41 class MjsunitTestSuite(testsuite.TestSuite): |
| 43 | 42 |
| 44 def __init__(self, name, root): | 43 def __init__(self, name, root): |
| 45 super(MjsunitTestSuite, self).__init__(name, root) | 44 super(MjsunitTestSuite, self).__init__(name, root) |
| 46 | 45 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 87 |
| 89 if MODULE_PATTERN.search(source): | 88 if MODULE_PATTERN.search(source): |
| 90 files.append("--module") | 89 files.append("--module") |
| 91 files.append(testfilename) | 90 files.append(testfilename) |
| 92 | 91 |
| 93 flags += files | 92 flags += files |
| 94 if context.isolates: | 93 if context.isolates: |
| 95 flags.append("--isolate") | 94 flags.append("--isolate") |
| 96 flags += files | 95 flags += files |
| 97 | 96 |
| 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 | |
| 104 return testcase.flags + flags | 97 return testcase.flags + flags |
| 105 | 98 |
| 106 def GetSourceForTest(self, testcase): | 99 def GetSourceForTest(self, testcase): |
| 107 filename = os.path.join(self.root, testcase.path + self.suffix()) | 100 filename = os.path.join(self.root, testcase.path + self.suffix()) |
| 108 with open(filename) as f: | 101 with open(filename) as f: |
| 109 return f.read() | 102 return f.read() |
| 110 | 103 |
| 111 | 104 |
| 112 def GetSuite(name, root): | 105 def GetSuite(name, root): |
| 113 return MjsunitTestSuite(name, root) | 106 return MjsunitTestSuite(name, root) |
| OLD | NEW |