| OLD | NEW |
| 1 # Copyright 2011 the V8 project authors. All rights reserved. | 1 # Copyright 2011 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 | 28 |
| 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:(.*)") |
| 38 INVALID_FLAGS = ["--enable-slow-asserts"] |
| 39 |
| 40 |
| 37 class PreparserTestSuite(testsuite.TestSuite): | 41 class PreparserTestSuite(testsuite.TestSuite): |
| 38 def __init__(self, name, root): | 42 def __init__(self, name, root): |
| 39 super(PreparserTestSuite, self).__init__(name, root) | 43 super(PreparserTestSuite, self).__init__(name, root) |
| 40 | 44 |
| 41 def shell(self): | 45 def shell(self): |
| 42 return "d8" | 46 return "d8" |
| 43 | 47 |
| 44 def _GetExpectations(self): | 48 def _GetExpectations(self): |
| 45 expects_file = os.path.join(self.root, "preparser.expectation") | 49 expects_file = os.path.join(self.root, "preparser.expectation") |
| 46 expectations_map = {} | 50 expectations_map = {} |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 filenames = [f[:-4] for f in os.listdir(self.root) if f.endswith(".pyt")] | 101 filenames = [f[:-4] for f in os.listdir(self.root) if f.endswith(".pyt")] |
| 98 filenames.sort() | 102 filenames.sort() |
| 99 for f in filenames: | 103 for f in filenames: |
| 100 self._ParsePythonTestTemplates(result, f) | 104 self._ParsePythonTestTemplates(result, f) |
| 101 return result | 105 return result |
| 102 | 106 |
| 103 def GetFlagsForTestCase(self, testcase, context): | 107 def GetFlagsForTestCase(self, testcase, context): |
| 104 first = testcase.flags[0] | 108 first = testcase.flags[0] |
| 105 if first != "-e": | 109 if first != "-e": |
| 106 testcase.flags[0] = os.path.join(self.root, first) | 110 testcase.flags[0] = os.path.join(self.root, first) |
| 111 source = self.GetSourceForTest(testcase) |
| 112 result = [] |
| 113 flags_match = re.findall(FLAGS_PATTERN, source) |
| 114 for match in flags_match: |
| 115 result += match.strip().split() |
| 116 result += context.mode_flags |
| 117 result = [x for x in result if x not in INVALID_FLAGS] |
| 118 result.append(os.path.join(self.root, testcase.path + ".js")) |
| 119 return testcase.flags + result |
| 107 return testcase.flags | 120 return testcase.flags |
| 108 | 121 |
| 109 def GetSourceForTest(self, testcase): | 122 def GetSourceForTest(self, testcase): |
| 110 if testcase.flags[0] == "-e": | 123 if testcase.flags[0] == "-e": |
| 111 return testcase.flags[1] | 124 return testcase.flags[1] |
| 112 with open(testcase.flags[0]) as f: | 125 with open(testcase.flags[0]) as f: |
| 113 return f.read() | 126 return f.read() |
| 114 | 127 |
| 115 def VariantFlags(self, testcase, default_flags): | 128 def VariantFlags(self, testcase, default_flags): |
| 116 return [[]]; | 129 return [[]]; |
| 117 | 130 |
| 118 | 131 |
| 119 def GetSuite(name, root): | 132 def GetSuite(name, root): |
| 120 return PreparserTestSuite(name, root) | 133 return PreparserTestSuite(name, root) |
| OLD | NEW |