OLD | NEW |
1 # Copyright 2012 the V8 project authors. All rights reserved. | 1 # Copyright 2012 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 23 matching lines...) Expand all Loading... |
34 | 34 |
35 class TestSuite(object): | 35 class TestSuite(object): |
36 | 36 |
37 @staticmethod | 37 @staticmethod |
38 def LoadTestSuite(root): | 38 def LoadTestSuite(root): |
39 name = root.split(os.path.sep)[-1] | 39 name = root.split(os.path.sep)[-1] |
40 f = None | 40 f = None |
41 try: | 41 try: |
42 (f, pathname, description) = imp.find_module("testcfg", [root]) | 42 (f, pathname, description) = imp.find_module("testcfg", [root]) |
43 module = imp.load_module("testcfg", f, pathname, description) | 43 module = imp.load_module("testcfg", f, pathname, description) |
44 return module.GetSuite(name, root) | 44 suite = module.GetSuite(name, root) |
45 except: | |
46 # Use default if no testcfg is present. | |
47 return GoogleTestSuite(name, root) | |
48 finally: | 45 finally: |
49 if f: | 46 if f: |
50 f.close() | 47 f.close() |
| 48 return suite |
51 | 49 |
52 def __init__(self, name, root): | 50 def __init__(self, name, root): |
53 self.name = name # string | 51 self.name = name # string |
54 self.root = root # string containing path | 52 self.root = root # string containing path |
55 self.tests = None # list of TestCase objects | 53 self.tests = None # list of TestCase objects |
56 self.rules = None # dictionary mapping test path to list of outcomes | 54 self.rules = None # dictionary mapping test path to list of outcomes |
57 self.wildcards = None # dictionary mapping test paths to list of outcomes | 55 self.wildcards = None # dictionary mapping test paths to list of outcomes |
58 self.total_duration = None # float, assigned on demand | 56 self.total_duration = None # float, assigned on demand |
59 | 57 |
60 def shell(self): | 58 def shell(self): |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 def StripOutputForTransmit(self, testcase): | 207 def StripOutputForTransmit(self, testcase): |
210 if not self.HasUnexpectedOutput(testcase): | 208 if not self.HasUnexpectedOutput(testcase): |
211 testcase.output.stdout = "" | 209 testcase.output.stdout = "" |
212 testcase.output.stderr = "" | 210 testcase.output.stderr = "" |
213 | 211 |
214 def CalculateTotalDuration(self): | 212 def CalculateTotalDuration(self): |
215 self.total_duration = 0.0 | 213 self.total_duration = 0.0 |
216 for t in self.tests: | 214 for t in self.tests: |
217 self.total_duration += t.duration | 215 self.total_duration += t.duration |
218 return self.total_duration | 216 return self.total_duration |
219 | |
220 | |
221 class GoogleTestSuite(TestSuite): | |
222 def __init__(self, name, root): | |
223 super(GoogleTestSuite, self).__init__(name, root) | |
224 | |
225 def ListTests(self, context): | |
226 shell = os.path.abspath(os.path.join(context.shell_dir, self.shell())) | |
227 if utils.IsWindows(): | |
228 shell += ".exe" | |
229 output = commands.Execute(context.command_prefix + | |
230 [shell, "--gtest_list_tests"] + | |
231 context.extra_flags) | |
232 if output.exit_code != 0: | |
233 print output.stdout | |
234 print output.stderr | |
235 return [] | |
236 tests = [] | |
237 test_case = '' | |
238 for line in output.stdout.splitlines(): | |
239 test_desc = line.strip().split()[0] | |
240 if test_desc.endswith('.'): | |
241 test_case = test_desc | |
242 elif test_case and test_desc: | |
243 test = testcase.TestCase(self, test_case + test_desc, dependency=None) | |
244 tests.append(test) | |
245 tests.sort() | |
246 return tests | |
247 | |
248 def GetFlagsForTestCase(self, testcase, context): | |
249 return (testcase.flags + ["--gtest_filter=" + testcase.path] + | |
250 ["--gtest_random_seed=%s" % context.random_seed] + | |
251 ["--gtest_print_time=0"] + | |
252 context.mode_flags) | |
253 | |
254 def shell(self): | |
255 return self.name | |
OLD | NEW |