| 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 18 matching lines...) Expand all Loading... |
| 29 import os | 29 import os |
| 30 import re | 30 import re |
| 31 | 31 |
| 32 from testrunner.local import testsuite | 32 from testrunner.local import testsuite |
| 33 from testrunner.local import utils | 33 from testrunner.local import utils |
| 34 from testrunner.objects import testcase | 34 from testrunner.objects import testcase |
| 35 | 35 |
| 36 | 36 |
| 37 FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") | 37 FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") |
| 38 INVALID_FLAGS = ["--enable-slow-asserts"] | 38 INVALID_FLAGS = ["--enable-slow-asserts"] |
| 39 MODULE_PATTERN = re.compile(r"^// MODULE$", flags=re.MULTILINE) |
| 39 | 40 |
| 40 | 41 |
| 41 class MessageTestSuite(testsuite.TestSuite): | 42 class MessageTestSuite(testsuite.TestSuite): |
| 42 def __init__(self, name, root): | 43 def __init__(self, name, root): |
| 43 super(MessageTestSuite, self).__init__(name, root) | 44 super(MessageTestSuite, self).__init__(name, root) |
| 44 | 45 |
| 45 def ListTests(self, context): | 46 def ListTests(self, context): |
| 46 tests = [] | 47 tests = [] |
| 47 for dirname, dirs, files in os.walk(self.root): | 48 for dirname, dirs, files in os.walk(self.root): |
| 48 for dotted in [x for x in dirs if x.startswith('.')]: | 49 for dotted in [x for x in dirs if x.startswith('.')]: |
| 49 dirs.remove(dotted) | 50 dirs.remove(dotted) |
| 50 dirs.sort() | 51 dirs.sort() |
| 51 files.sort() | 52 files.sort() |
| 52 for filename in files: | 53 for filename in files: |
| 53 if filename.endswith(".js"): | 54 if filename.endswith(".js"): |
| 54 testname = os.path.join(dirname[len(self.root) + 1:], filename[:-3]) | 55 testname = os.path.join(dirname[len(self.root) + 1:], filename[:-3]) |
| 55 test = testcase.TestCase(self, testname) | 56 test = testcase.TestCase(self, testname) |
| 56 tests.append(test) | 57 tests.append(test) |
| 57 return tests | 58 return tests |
| 58 | 59 |
| 59 def GetFlagsForTestCase(self, testcase, context): | 60 def GetFlagsForTestCase(self, testcase, context): |
| 60 source = self.GetSourceForTest(testcase) | 61 source = self.GetSourceForTest(testcase) |
| 61 result = [] | 62 result = [] |
| 62 flags_match = re.findall(FLAGS_PATTERN, source) | 63 flags_match = re.findall(FLAGS_PATTERN, source) |
| 63 for match in flags_match: | 64 for match in flags_match: |
| 64 result += match.strip().split() | 65 result += match.strip().split() |
| 65 result += context.mode_flags | 66 result += context.mode_flags |
| 67 if MODULE_PATTERN.search(source): |
| 68 result.append("--module") |
| 66 result = [x for x in result if x not in INVALID_FLAGS] | 69 result = [x for x in result if x not in INVALID_FLAGS] |
| 67 result.append(os.path.join(self.root, testcase.path + ".js")) | 70 result.append(os.path.join(self.root, testcase.path + ".js")) |
| 68 return testcase.flags + result | 71 return testcase.flags + result |
| 69 | 72 |
| 70 def GetSourceForTest(self, testcase): | 73 def GetSourceForTest(self, testcase): |
| 71 filename = os.path.join(self.root, testcase.path + self.suffix()) | 74 filename = os.path.join(self.root, testcase.path + self.suffix()) |
| 72 with open(filename) as f: | 75 with open(filename) as f: |
| 73 return f.read() | 76 return f.read() |
| 74 | 77 |
| 75 def _IgnoreLine(self, string): | 78 def _IgnoreLine(self, string): |
| (...skipping 30 matching lines...) Expand all Loading... |
| 106 if not re.match(pattern, actual): | 109 if not re.match(pattern, actual): |
| 107 return True | 110 return True |
| 108 return False | 111 return False |
| 109 | 112 |
| 110 def StripOutputForTransmit(self, testcase): | 113 def StripOutputForTransmit(self, testcase): |
| 111 pass | 114 pass |
| 112 | 115 |
| 113 | 116 |
| 114 def GetSuite(name, root): | 117 def GetSuite(name, root): |
| 115 return MessageTestSuite(name, root) | 118 return MessageTestSuite(name, root) |
| OLD | NEW |