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 suite = module.GetSuite(name, root) | 44 return module.GetSuite(name, root) |
| 45 except: |
| 46 # Use default if no testcfg is present. |
| 47 return GoogleTestSuite(name, root) |
45 finally: | 48 finally: |
46 if f: | 49 if f: |
47 f.close() | 50 f.close() |
48 return suite | |
49 | 51 |
50 def __init__(self, name, root): | 52 def __init__(self, name, root): |
51 self.name = name # string | 53 self.name = name # string |
52 self.root = root # string containing path | 54 self.root = root # string containing path |
53 self.tests = None # list of TestCase objects | 55 self.tests = None # list of TestCase objects |
54 self.rules = None # dictionary mapping test path to list of outcomes | 56 self.rules = None # dictionary mapping test path to list of outcomes |
55 self.wildcards = None # dictionary mapping test paths to list of outcomes | 57 self.wildcards = None # dictionary mapping test paths to list of outcomes |
56 self.total_duration = None # float, assigned on demand | 58 self.total_duration = None # float, assigned on demand |
57 | 59 |
58 def shell(self): | 60 def shell(self): |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 def StripOutputForTransmit(self, testcase): | 209 def StripOutputForTransmit(self, testcase): |
208 if not self.HasUnexpectedOutput(testcase): | 210 if not self.HasUnexpectedOutput(testcase): |
209 testcase.output.stdout = "" | 211 testcase.output.stdout = "" |
210 testcase.output.stderr = "" | 212 testcase.output.stderr = "" |
211 | 213 |
212 def CalculateTotalDuration(self): | 214 def CalculateTotalDuration(self): |
213 self.total_duration = 0.0 | 215 self.total_duration = 0.0 |
214 for t in self.tests: | 216 for t in self.tests: |
215 self.total_duration += t.duration | 217 self.total_duration += t.duration |
216 return self.total_duration | 218 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 |