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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 serialization_file += ''.join(testcase.flags).replace('-', '_') | 77 serialization_file += ''.join(testcase.flags).replace('-', '_') |
78 return (testcase.flags + [testcase.path] + context.mode_flags + | 78 return (testcase.flags + [testcase.path] + context.mode_flags + |
79 ["--testing_serialization_file=" + serialization_file]) | 79 ["--testing_serialization_file=" + serialization_file]) |
80 | 80 |
81 def shell(self): | 81 def shell(self): |
82 return "cctest" | 82 return "cctest" |
83 | 83 |
84 | 84 |
85 def GetSuite(name, root): | 85 def GetSuite(name, root): |
86 return CcTestSuite(name, root) | 86 return CcTestSuite(name, root) |
87 | |
88 | |
89 # Deprecated definitions below. | |
90 # TODO(jkummerow): Remove when SCons is no longer supported. | |
91 | |
92 | |
93 from os.path import exists, join, normpath | |
94 import test | |
95 | |
96 | |
97 class CcTestCase(test.TestCase): | |
98 | |
99 def __init__(self, path, executable, mode, raw_name, dependency, context, vari
ant_flags): | |
100 super(CcTestCase, self).__init__(context, path, mode) | |
101 self.executable = executable | |
102 self.raw_name = raw_name | |
103 self.dependency = dependency | |
104 self.variant_flags = variant_flags | |
105 | |
106 def GetLabel(self): | |
107 return "%s %s %s" % (self.mode, self.path[-2], self.path[-1]) | |
108 | |
109 def GetName(self): | |
110 return self.path[-1] | |
111 | |
112 def BuildCommand(self, name): | |
113 serialization_file = '' | |
114 if exists(join(self.context.buildspace, 'obj', 'test', self.mode)): | |
115 serialization_file = join('obj', 'test', self.mode, 'serdes') | |
116 else: | |
117 serialization_file = join('obj', 'serdes') | |
118 if not exists(join(self.context.buildspace, 'obj')): | |
119 os.makedirs(join(self.context.buildspace, 'obj')) | |
120 serialization_file += '_' + self.GetName() | |
121 serialization_file = join(self.context.buildspace, serialization_file) | |
122 serialization_file += ''.join(self.variant_flags).replace('-', '_') | |
123 serialization_option = '--testing_serialization_file=' + serialization_file | |
124 result = [ self.executable, name, serialization_option ] | |
125 result += self.context.GetVmFlags(self, self.mode) | |
126 return result | |
127 | |
128 def GetCommand(self): | |
129 return self.BuildCommand(self.raw_name) | |
130 | |
131 def Run(self): | |
132 if self.dependency != '': | |
133 dependent_command = self.BuildCommand(self.dependency) | |
134 output = self.RunCommand(dependent_command) | |
135 if output.HasFailed(): | |
136 return output | |
137 return test.TestCase.Run(self) | |
138 | |
139 | |
140 class CcTestConfiguration(test.TestConfiguration): | |
141 | |
142 def __init__(self, context, root): | |
143 super(CcTestConfiguration, self).__init__(context, root) | |
144 | |
145 def GetBuildRequirements(self): | |
146 return ['cctests'] | |
147 | |
148 def ListTests(self, current_path, path, mode, variant_flags): | |
149 executable = 'cctest' | |
150 if utils.IsWindows(): | |
151 executable += '.exe' | |
152 executable = join(self.context.buildspace, executable) | |
153 if not exists(executable): | |
154 executable = join('obj', 'test', mode, 'cctest') | |
155 if utils.IsWindows(): | |
156 executable += '.exe' | |
157 executable = join(self.context.buildspace, executable) | |
158 full_command = self.context.processor([executable, '--list']) | |
159 output = test.Execute(full_command, self.context) | |
160 if output.exit_code != 0: | |
161 print output.stdout | |
162 print output.stderr | |
163 return [] | |
164 result = [] | |
165 for test_desc in output.stdout.strip().split(): | |
166 raw_test, dependency = test_desc.split('<') | |
167 relative_path = raw_test.split('/') | |
168 full_path = current_path + relative_path | |
169 if dependency != '': | |
170 dependency = relative_path[0] + '/' + dependency | |
171 if self.Contains(path, full_path): | |
172 result.append(CcTestCase(full_path, executable, mode, raw_test, dependen
cy, self.context, variant_flags)) | |
173 result.sort() | |
174 return result | |
175 | |
176 def GetTestStatus(self, sections, defs): | |
177 status_file = join(self.root, 'cctest.status') | |
178 if exists(status_file): | |
179 test.ReadConfigurationInto(status_file, sections, defs) | |
180 | |
181 | |
182 def GetConfiguration(context, root): | |
183 return CcTestConfiguration(context, root) | |
OLD | NEW |