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

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: Removed code in comments 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
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 if arch in ['ia32', 'x64', 'simarm', 'arm']:
74 test_path, filename, mode, arch)) 77 # Look for VM specified as comments in teh source file. If
Ivan Posva 2011/10/13 07:17:34 Look for VM options specified... teh -> the
Søren Gjesse 2011/10/13 07:28:15 Done.
78 # several sets of VM options are specified create a separate
79 # test for each set.
80 source = file(filename).read()
81 vm_options = utils.ParseTestOptionsMultiple(VM_OPTIONS_PATTERN,
82 source,
83 test_path)
84 if vm_options:
85 for options in vm_options:
86 tests.append(test_case.StandardTestCase(self.context,
87 test_path, filename, mode, arch, options))
88 else:
89 tests.append(test_case.StandardTestCase(self.context,
90 test_path, filename, mode, arch))
91 else:
92 tests.append(test_case.StandardTestCase(self.context,
93 test_path, filename, mode, arch))
75 return tests 94 return tests
76 95
77 def ListTests(self, current_path, path, mode, arch): 96 def ListTests(self, current_path, path, mode, arch):
78 tests = [] 97 tests = []
79 for root, dirs, files in os.walk(join(self.root, 'src')): 98 for root, dirs, files in os.walk(join(self.root, 'src')):
80 for f in [x for x in files if self.IsTest(x)]: 99 for f in [x for x in files if self.IsTest(x)]:
81 if f.endswith(".dart"): 100 if f.endswith(".dart"):
82 test_path = current_path + [ f[:-5] ] # Remove .dart suffix. 101 test_path = current_path + [ f[:-5] ] # Remove .dart suffix.
83 elif f.endswith(".app"): 102 elif f.endswith(".app"):
84 test_path = current_path + [ f[:-4] ] # Remove .app suffix. 103 test_path = current_path + [ f[:-4] ] # Remove .app suffix.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 return tests 181 return tests
163 182
164 class BrowserTestCase(test_case.StandardTestCase): 183 class BrowserTestCase(test_case.StandardTestCase):
165 def __init__(self, context, path, filename, 184 def __init__(self, context, path, filename,
166 fatal_static_type_errors, mode, arch): 185 fatal_static_type_errors, mode, arch):
167 super(test_case.BrowserTestCase, self).__init__(context, path, filename, mod e, arch) 186 super(test_case.BrowserTestCase, self).__init__(context, path, filename, mod e, arch)
168 self.fatal_static_type_errors = fatal_static_type_errors 187 self.fatal_static_type_errors = fatal_static_type_errors
169 188
170 def IsBatchable(self): 189 def IsBatchable(self):
171 return True 190 return True
172 191
173 def Run(self): 192 def Run(self):
174 command = self.run_arch.GetCompileCommand(self.fatal_static_type_errors) 193 command = self.run_arch.GetCompileCommand(self.fatal_static_type_errors)
175 if command != None: 194 if command != None:
176 # We change the directory where dartc will be launched because 195 # We change the directory where dartc will be launched because
177 # it is not predictable on the location of the compiled file. In 196 # 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 197 # case the test is a web test, we make sure the app file is not
179 # in a subdirectory. 198 # in a subdirectory.
180 cwd = None 199 cwd = None
181 if self.run_arch.is_web_test: cwd = self.run_arch.temp_dir 200 if self.run_arch.is_web_test: cwd = self.run_arch.temp_dir
182 command = command[:1] + self.context.flags + command[1:] 201 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)): 261 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('.')] 262 ignore_dirs = [d for d in dirs if d.startswith('.')]
244 for d in ignore_dirs: 263 for d in ignore_dirs:
245 dirs.remove(d) 264 dirs.remove(d)
246 for f in files: 265 for f in files:
247 filename = [os.path.basename(client_path)] 266 filename = [os.path.basename(client_path)]
248 filename.extend(root[len(client_path) + 1:].split(os.path.sep)) 267 filename.extend(root[len(client_path) + 1:].split(os.path.sep))
249 filename.append(f) # Remove .lib or .app suffix. 268 filename.append(f) # Remove .lib or .app suffix.
250 test_path = current_path + filename 269 test_path = current_path + filename
251 test_dart_file = os.path.join(root, f) 270 test_dart_file = os.path.join(root, f)
252 if ((not self.Contains(path, test_path)) 271 if ((not self.Contains(path, test_path))
253 or (not self.IsTest(test_dart_file))): 272 or (not self.IsTest(test_dart_file))):
254 continue 273 continue
255 tests.append(test_case.CompilationTestCase(test_path, 274 tests.append(test_case.CompilationTestCase(test_path,
256 self.context, 275 self.context,
257 test_dart_file, 276 test_dart_file,
258 mode, 277 mode,
259 arch)) 278 arch))
260 atexit.register(lambda: self._cleanup(tests)) 279 atexit.register(lambda: self._cleanup(tests))
261 return tests 280 return tests
262 281
(...skipping 17 matching lines...) Expand all
280 299
281 def GetTestStatus(self, sections, defs): 300 def GetTestStatus(self, sections, defs):
282 status = os.path.join(self.root, 'dartc.status') 301 status = os.path.join(self.root, 'dartc.status')
283 if os.path.exists(status): 302 if os.path.exists(status):
284 test.ReadConfigurationInto(status, sections, defs) 303 test.ReadConfigurationInto(status, sections, defs)
285 304
286 def _cleanup(self, tests): 305 def _cleanup(self, tests):
287 if not utils.Daemonize(): return 306 if not utils.Daemonize(): return
288 os.execlp('rm', *(['rm', '-rf'] + [t.temp_dir for t in tests])) 307 os.execlp('rm', *(['rm', '-rf'] + [t.temp_dir for t in tests]))
289 raise 308 raise
OLDNEW
« tools/testing/architecture.py ('K') | « tools/testing/test_case.py ('k') | tools/utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698