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 13 matching lines...) Expand all Loading... |
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 import test | 28 import test |
29 import os | 29 import os |
30 from os.path import join, dirname, exists | 30 from os.path import join, dirname, exists |
31 import re | 31 import re |
32 import tempfile | 32 import tempfile |
33 | 33 |
34 | 34 MJSUNIT_DEBUG_FLAGS = ['--enable-slow-asserts', '--debug-code', '--verify-heap'] |
35 FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") | 35 FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") |
36 FILES_PATTERN = re.compile(r"//\s+Files:(.*)") | 36 FILES_PATTERN = re.compile(r"//\s+Files:(.*)") |
37 SELF_SCRIPT_PATTERN = re.compile(r"//\s+Env: TEST_FILE_NAME") | 37 SELF_SCRIPT_PATTERN = re.compile(r"//\s+Env: TEST_FILE_NAME") |
38 | 38 |
39 | 39 |
40 class MjsunitTestCase(test.TestCase): | 40 class MjsunitTestCase(test.TestCase): |
41 | 41 |
42 def __init__(self, path, file, mode, context, config): | 42 def __init__(self, path, file, mode, context, config): |
43 super(MjsunitTestCase, self).__init__(context, path) | 43 super(MjsunitTestCase, self).__init__(context, path) |
44 self.file = file | 44 self.file = file |
45 self.config = config | 45 self.config = config |
46 self.mode = mode | 46 self.mode = mode |
47 self.self_script = False | 47 self.self_script = False |
48 | 48 |
49 def GetLabel(self): | 49 def GetLabel(self): |
50 return "%s %s" % (self.mode, self.GetName()) | 50 return "%s %s" % (self.mode, self.GetName()) |
51 | 51 |
52 def GetName(self): | 52 def GetName(self): |
53 return self.path[-1] | 53 return self.path[-1] |
54 | 54 |
55 def GetCommand(self): | 55 def GetCommand(self): |
56 result = [self.config.context.GetVm(self.mode)] | 56 result = [self.config.context.GetVm(self.mode)] |
57 source = open(self.file).read() | 57 source = open(self.file).read() |
58 flags_match = FLAGS_PATTERN.search(source) | 58 flags_match = FLAGS_PATTERN.search(source) |
59 if flags_match: | 59 if flags_match: |
60 result += flags_match.group(1).strip().split() | 60 result += flags_match.group(1).strip().split() |
| 61 if self.mode == 'debug': |
| 62 result += MJSUNIT_DEBUG_FLAGS |
61 additional_files = [] | 63 additional_files = [] |
62 files_match = FILES_PATTERN.search(source); | 64 files_match = FILES_PATTERN.search(source); |
63 # Accept several lines of 'Files:' | 65 # Accept several lines of 'Files:' |
64 while True: | 66 while True: |
65 if files_match: | 67 if files_match: |
66 additional_files += files_match.group(1).strip().split() | 68 additional_files += files_match.group(1).strip().split() |
67 files_match = FILES_PATTERN.search(source, files_match.end()) | 69 files_match = FILES_PATTERN.search(source, files_match.end()) |
68 else: | 70 else: |
69 break | 71 break |
70 for a_file in additional_files: | 72 for a_file in additional_files: |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 126 |
125 def GetTestStatus(self, sections, defs): | 127 def GetTestStatus(self, sections, defs): |
126 status_file = join(self.root, 'mjsunit.status') | 128 status_file = join(self.root, 'mjsunit.status') |
127 if exists(status_file): | 129 if exists(status_file): |
128 test.ReadConfigurationInto(status_file, sections, defs) | 130 test.ReadConfigurationInto(status_file, sections, defs) |
129 | 131 |
130 | 132 |
131 | 133 |
132 def GetConfiguration(context, root): | 134 def GetConfiguration(context, root): |
133 return MjsunitTestConfiguration(context, root) | 135 return MjsunitTestConfiguration(context, root) |
OLD | NEW |