Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: tools/testing/test_configuration.py

Issue 8226016: Add the ability to run tests with several sets of VM flags (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments from ngeoffray@ Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/testing/test_case.py ('k') | tools/utils.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 # for details. All rights reserved. Use of this source code is governed by a 2 # for details. All rights reserved. Use of this source code is governed by a
3 # BSD-style license that can be found in the LICENSE file. 3 # BSD-style license that can be found in the LICENSE file.
4 4
5 import atexit 5 import atexit
6 import fileinput 6 import fileinput
7 import os 7 import os
8 import test 8 import test
9 import platform 9 import platform
10 import re 10 import re
11 import shutil 11 import shutil
12 import sys 12 import sys
13 import tempfile 13 import tempfile
14 14
15 from testing import test_case 15 from testing import test_case
16 import test 16 import test
17 import utils 17 import utils
18 18
19 from os.path import join, exists, basename 19 from os.path import join, exists, basename
20 20
21 import utils 21 import utils
22 22
23 # Patterns for matching test options in .dart files.
24 VM_OPTIONS_PATTERN = re.compile(r"// VMOptions=(.*)")
25
23 class Error(Exception): 26 class Error(Exception):
24 pass 27 pass
25 28
26 class TestConfigurationError(Error): 29 class TestConfigurationError(Error):
27 pass 30 pass
28 31
29 class StandardTestConfiguration(test.TestConfiguration): 32 class StandardTestConfiguration(test.TestConfiguration):
30 LEGAL_KINDS = set(['compile-time error', 33 LEGAL_KINDS = set(['compile-time error',
31 'runtime error', 34 'runtime error',
32 'static type error', 35 'static type error',
(...skipping 30 matching lines...) Expand all
63 else: 66 else:
64 tests = [] 67 tests = []
65 if tags: 68 if tags:
66 for tag in sorted(tags): 69 for tag in sorted(tags):
67 kind, test_source = tags[tag] 70 kind, test_source = tags[tag]
68 if not self.Contains(path, test_path + [tag]): 71 if not self.Contains(path, test_path + [tag]):
69 continue 72 continue
70 tests.append(test_case.MultiTestCase(self.context, 73 tests.append(test_case.MultiTestCase(self.context,
71 test_path + [tag], test_source, kind, mode, arch)) 74 test_path + [tag], test_source, kind, mode, arch))
72 else: 75 else:
73 tests.append(test_case.StandardTestCase(self.context, 76 # Look for VM specified as comments in the source file. If
74 test_path, filename, mode, arch)) 77 # several sets of VM options are specified create a separate
78 # test for each set.
79 source = file(filename).read()
80 vm_options_list = utils.ParseTestOptionsMultiple(VM_OPTIONS_PATTERN,
81 source,
82 test_path)
83 if vm_options_list:
84 for options in vm_options_list:
85 tests.append(test_case.StandardTestCase(self.context,
86 test_path, filename, mode, arch, options))
87 else:
88 tests.append(test_case.StandardTestCase(self.context,
89 test_path, filename, mode, arch))
75 return tests 90 return tests
76 91
77 def ListTests(self, current_path, path, mode, arch): 92 def ListTests(self, current_path, path, mode, arch):
78 tests = [] 93 tests = []
79 for root, dirs, files in os.walk(join(self.root, 'src')): 94 for root, dirs, files in os.walk(join(self.root, 'src')):
80 for f in [x for x in files if self.IsTest(x)]: 95 for f in [x for x in files if self.IsTest(x)]:
81 if f.endswith(".dart"): 96 if f.endswith(".dart"):
82 test_path = current_path + [ f[:-5] ] # Remove .dart suffix. 97 test_path = current_path + [ f[:-5] ] # Remove .dart suffix.
83 elif f.endswith(".app"): 98 elif f.endswith(".app"):
84 test_path = current_path + [ f[:-4] ] # Remove .app suffix. 99 test_path = current_path + [ f[:-4] ] # Remove .app suffix.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 return tests 177 return tests
163 178
164 class BrowserTestCase(test_case.StandardTestCase): 179 class BrowserTestCase(test_case.StandardTestCase):
165 def __init__(self, context, path, filename, 180 def __init__(self, context, path, filename,
166 fatal_static_type_errors, mode, arch): 181 fatal_static_type_errors, mode, arch):
167 super(test_case.BrowserTestCase, self).__init__(context, path, filename, mod e, arch) 182 super(test_case.BrowserTestCase, self).__init__(context, path, filename, mod e, arch)
168 self.fatal_static_type_errors = fatal_static_type_errors 183 self.fatal_static_type_errors = fatal_static_type_errors
169 184
170 def IsBatchable(self): 185 def IsBatchable(self):
171 return True 186 return True
172 187
173 def Run(self): 188 def Run(self):
174 command = self.run_arch.GetCompileCommand(self.fatal_static_type_errors) 189 command = self.run_arch.GetCompileCommand(self.fatal_static_type_errors)
175 if command != None: 190 if command != None:
176 # We change the directory where dartc will be launched because 191 # We change the directory where dartc will be launched because
177 # it is not predictable on the location of the compiled file. In 192 # it is not predictable on the location of the compiled file. In
178 # case the test is a web test, we make sure the app file is not 193 # case the test is a web test, we make sure the app file is not
179 # in a subdirectory. 194 # in a subdirectory.
180 cwd = None 195 cwd = None
181 if self.run_arch.is_web_test: cwd = self.run_arch.temp_dir 196 if self.run_arch.is_web_test: cwd = self.run_arch.temp_dir
182 command = command[:1] + self.context.flags + command[1:] 197 command = command[:1] + self.context.flags + command[1:]
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 for root, dirs, files in os.walk(os.path.join(client_path, src_dir)): 257 for root, dirs, files in os.walk(os.path.join(client_path, src_dir)):
243 ignore_dirs = [d for d in dirs if d.startswith('.')] 258 ignore_dirs = [d for d in dirs if d.startswith('.')]
244 for d in ignore_dirs: 259 for d in ignore_dirs:
245 dirs.remove(d) 260 dirs.remove(d)
246 for f in files: 261 for f in files:
247 filename = [os.path.basename(client_path)] 262 filename = [os.path.basename(client_path)]
248 filename.extend(root[len(client_path) + 1:].split(os.path.sep)) 263 filename.extend(root[len(client_path) + 1:].split(os.path.sep))
249 filename.append(f) # Remove .lib or .app suffix. 264 filename.append(f) # Remove .lib or .app suffix.
250 test_path = current_path + filename 265 test_path = current_path + filename
251 test_dart_file = os.path.join(root, f) 266 test_dart_file = os.path.join(root, f)
252 if ((not self.Contains(path, test_path)) 267 if ((not self.Contains(path, test_path))
253 or (not self.IsTest(test_dart_file))): 268 or (not self.IsTest(test_dart_file))):
254 continue 269 continue
255 tests.append(test_case.CompilationTestCase(test_path, 270 tests.append(test_case.CompilationTestCase(test_path,
256 self.context, 271 self.context,
257 test_dart_file, 272 test_dart_file,
258 mode, 273 mode,
259 arch)) 274 arch))
260 atexit.register(lambda: self._cleanup(tests)) 275 atexit.register(lambda: self._cleanup(tests))
261 return tests 276 return tests
262 277
(...skipping 17 matching lines...) Expand all
280 295
281 def GetTestStatus(self, sections, defs): 296 def GetTestStatus(self, sections, defs):
282 status = os.path.join(self.root, 'dartc.status') 297 status = os.path.join(self.root, 'dartc.status')
283 if os.path.exists(status): 298 if os.path.exists(status):
284 test.ReadConfigurationInto(status, sections, defs) 299 test.ReadConfigurationInto(status, sections, defs)
285 300
286 def _cleanup(self, tests): 301 def _cleanup(self, tests):
287 if not utils.Daemonize(): return 302 if not utils.Daemonize(): return
288 os.execlp('rm', *(['rm', '-rf'] + [t.temp_dir for t in tests])) 303 os.execlp('rm', *(['rm', '-rf'] + [t.temp_dir for t in tests]))
289 raise 304 raise
OLDNEW
« no previous file with comments | « tools/testing/test_case.py ('k') | tools/utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698