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

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

Issue 8408002: Add a new variable environment for testing, to replace the misusage of 'arch'. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 1 month 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
« dart/tools/test.py ('K') | « dart/tools/testing/test_case.py ('k') | no next file » | 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 """Common Testconfiguration subclasses used to define a class of tests.""" 5 """Common Testconfiguration subclasses used to define a class of tests."""
6 6
7 import atexit 7 import atexit
8 import fileinput 8 import fileinput
9 import os 9 import os
10 import re 10 import re
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 if t.run_arch: 47 if t.run_arch:
48 temp_dir = t.run_arch.temp_dir 48 temp_dir = t.run_arch.temp_dir
49 if temp_dir: 49 if temp_dir:
50 dirs.append(temp_dir) 50 dirs.append(temp_dir)
51 if not dirs: 51 if not dirs:
52 return 52 return
53 if not utils.Daemonize(): 53 if not utils.Daemonize():
54 return 54 return
55 os.execlp('rm', *(['rm', '-rf'] + dirs)) 55 os.execlp('rm', *(['rm', '-rf'] + dirs))
56 56
57 def CreateTestCases(self, test_path, path, filename, mode, arch): 57 def CreateTestCases(self, test_path, path, filename, mode, arch, FOOBAR):
58 """Given a .dart filename, create a StandardTestCase from it.""" 58 """Given a .dart filename, create a StandardTestCase from it."""
59 # Look for VM specified as comments in the source file. If 59 # Look for VM specified as comments in the source file. If
60 # several sets of VM options are specified create a separate 60 # several sets of VM options are specified create a separate
61 # test for each set. 61 # test for each set.
62 source = file(filename).read() 62 source = file(filename).read()
63 vm_options_list = utils.ParseTestOptionsMultiple(VM_OPTIONS_PATTERN, 63 vm_options_list = utils.ParseTestOptionsMultiple(VM_OPTIONS_PATTERN,
64 source, 64 source,
65 test_path) 65 test_path)
66 tags = {} 66 tags = {}
67 if filename.endswith('.dart'): 67 if filename.endswith('.dart'):
68 tags = self.SplitMultiTest(test_path, filename) 68 tags = self.SplitMultiTest(test_path, filename)
69 if arch in ['dartium', 'chromium']: 69 if FOOBAR in ['dartium', 'chromium']:
70 if tags: 70 if tags:
71 return [] 71 return []
72 else: 72 else:
73 if vm_options_list: 73 if vm_options_list:
74 tests = [] 74 tests = []
75 for options in vm_options_list: 75 for options in vm_options_list:
76 tests.append(test_case.BrowserTestCase( 76 tests.append(test_case.BrowserTestCase(
77 self.context, test_path, filename, False, mode, arch, options)) 77 self.context, test_path, filename, False, mode, arch, FOOBAR, op tions))
78 return tests 78 return tests
79 else: 79 else:
80 return [test_case.BrowserTestCase( 80 return [test_case.BrowserTestCase(
81 self.context, test_path, filename, False, mode, arch)] 81 self.context, test_path, filename, False, mode, arch, FOOBAR)]
82 else: 82 else:
83 tests = [] 83 tests = []
84 if tags: 84 if tags:
85 for tag in sorted(tags): 85 for tag in sorted(tags):
86 kind, test_source = tags[tag] 86 kind, test_source = tags[tag]
87 if not self.Contains(path, test_path + [tag]): 87 if not self.Contains(path, test_path + [tag]):
88 continue 88 continue
89 tests.append(test_case.MultiTestCase(self.context, 89 tests.append(test_case.MultiTestCase(self.context,
90 test_path + [tag], 90 test_path + [tag],
91 test_source, 91 test_source,
92 kind, 92 kind,
93 mode, arch)) 93 mode, arch, FOOBAR))
94 else: 94 else:
95 if vm_options_list: 95 if vm_options_list:
96 for options in vm_options_list: 96 for options in vm_options_list:
97 tests.append(test_case.StandardTestCase(self.context, 97 tests.append(test_case.StandardTestCase(self.context,
98 test_path, filename, mode, arch, options)) 98 test_path, filename, mode, arch, FOOBAR, options))
99 else: 99 else:
100 tests.append(test_case.StandardTestCase(self.context, 100 tests.append(test_case.StandardTestCase(self.context,
101 test_path, filename, mode, arch)) 101 test_path, filename, mode, arch, FOOBAR))
102 return tests 102 return tests
103 103
104 def ListTests(self, current_path, path, mode, arch): 104 def ListTests(self, current_path, path, mode, arch, FOOBAR):
105 """Searches for *Test.dart files and returns list of TestCases.""" 105 """Searches for *Test.dart files and returns list of TestCases."""
106 tests = [] 106 tests = []
107 for root, unused_dirs, files in os.walk(os.path.join(self.root, 'src')): 107 for root, unused_dirs, files in os.walk(os.path.join(self.root, 'src')):
108 for f in [x for x in files if self.IsTest(x)]: 108 for f in [x for x in files if self.IsTest(x)]:
109 if f.endswith('.dart'): 109 if f.endswith('.dart'):
110 test_path = current_path + [f[:-5]] # Remove .dart suffix. 110 test_path = current_path + [f[:-5]] # Remove .dart suffix.
111 elif f.endswith('.app'): 111 elif f.endswith('.app'):
112 # TODO(zundel): .app files are used only the dromaeo test 112 # TODO(zundel): .app files are used only the dromaeo test
113 # and should be removed. 113 # and should be removed.
114 test_path = current_path + [f[:-4]] # Remove .app suffix. 114 test_path = current_path + [f[:-4]] # Remove .app suffix.
115 if not self.Contains(path, test_path): 115 if not self.Contains(path, test_path):
116 continue 116 continue
117 tests.extend(self.CreateTestCases(test_path, path, 117 tests.extend(self.CreateTestCases(test_path, path,
118 os.path.join(root, f), 118 os.path.join(root, f),
119 mode, arch)) 119 mode, arch, FOOBAR))
120 atexit.register(lambda: self._Cleanup(tests)) 120 atexit.register(lambda: self._Cleanup(tests))
121 return tests 121 return tests
122 122
123 def IsTest(self, name): 123 def IsTest(self, name):
124 """Returns True if the file name is a test file.""" 124 """Returns True if the file name is a test file."""
125 return name.endswith('Test.dart') or name.endswith('Test.app') 125 return name.endswith('Test.dart') or name.endswith('Test.app')
126 126
127 def GetTestStatus(self, sections, defs): 127 def GetTestStatus(self, sections, defs):
128 """Reads the .status file of the TestSuite.""" 128 """Reads the .status file of the TestSuite."""
129 status = os.path.join(self.root, os.path.basename(self.root) + '.status') 129 status = os.path.join(self.root, os.path.basename(self.root) + '.status')
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 return tests 213 return tests
214 214
215 215
216 class BrowserTestConfiguration(StandardTestConfiguration): 216 class BrowserTestConfiguration(StandardTestConfiguration):
217 """A configuration used to run tests inside a browser.""" 217 """A configuration used to run tests inside a browser."""
218 218
219 def __init__(self, context, root, fatal_static_type_errors=False): 219 def __init__(self, context, root, fatal_static_type_errors=False):
220 super(BrowserTestConfiguration, self).__init__(context, root) 220 super(BrowserTestConfiguration, self).__init__(context, root)
221 self.fatal_static_type_errors = fatal_static_type_errors 221 self.fatal_static_type_errors = fatal_static_type_errors
222 222
223 def ListTests(self, current_path, path, mode, arch): 223 def ListTests(self, current_path, path, mode, arch, FOOBAR):
224 """Searches for *Test .dart files and returns list of TestCases.""" 224 """Searches for *Test .dart files and returns list of TestCases."""
225 tests = [] 225 tests = []
226 for root, unused_dirs, files in os.walk(self.root): 226 for root, unused_dirs, files in os.walk(self.root):
227 for f in [x for x in files if self.IsTest(x)]: 227 for f in [x for x in files if self.IsTest(x)]:
228 relative = os.path.relpath(root, self.root).split(os.path.sep) 228 relative = os.path.relpath(root, self.root).split(os.path.sep)
229 test_path = current_path + relative + [os.path.splitext(f)[0]] 229 test_path = current_path + relative + [os.path.splitext(f)[0]]
230 if not self.Contains(path, test_path): 230 if not self.Contains(path, test_path):
231 continue 231 continue
232 tests.append(test_case.BrowserTestCase(self.context, 232 tests.append(test_case.BrowserTestCase(self.context,
233 test_path, 233 test_path,
234 os.path.join(root, f), 234 os.path.join(root, f),
235 self.fatal_static_type_errors, 235 self.fatal_static_type_errors,
236 mode, arch)) 236 mode, arch, FOOBAR))
237 atexit.register(lambda: self._Cleanup(tests)) 237 atexit.register(lambda: self._Cleanup(tests))
238 return tests 238 return tests
239 239
240 def IsTest(self, name): 240 def IsTest(self, name):
241 return name.endswith('_tests.dart') 241 return name.endswith('_tests.dart')
242 242
243 243
244 class CompilationTestConfiguration(test.TestConfiguration): 244 class CompilationTestConfiguration(test.TestConfiguration):
245 """Configuration that searches specific directories for apps to compile. 245 """Configuration that searches specific directories for apps to compile.
246 246
247 Expects a status file named dartc.status 247 Expects a status file named dartc.status
248 """ 248 """
249 249
250 def __init__(self, context, root): 250 def __init__(self, context, root):
251 super(CompilationTestConfiguration, self).__init__(context, root) 251 super(CompilationTestConfiguration, self).__init__(context, root)
252 252
253 def ListTests(self, current_path, path, mode, arch): 253 def ListTests(self, current_path, path, mode, arch, FOOBAR):
254 """Searches for *Test.dart files and returns list of TestCases.""" 254 """Searches for *Test.dart files and returns list of TestCases."""
255 tests = [] 255 tests = []
256 client_path = os.path.normpath(os.path.join(self.root, '..', '..')) 256 client_path = os.path.normpath(os.path.join(self.root, '..', '..'))
257 257
258 for src_dir in self.SourceDirs(): 258 for src_dir in self.SourceDirs():
259 for root, dirs, files in os.walk(os.path.join(client_path, src_dir)): 259 for root, dirs, files in os.walk(os.path.join(client_path, src_dir)):
260 ignore_dirs = [d for d in dirs if d.startswith('.')] 260 ignore_dirs = [d for d in dirs if d.startswith('.')]
261 for d in ignore_dirs: 261 for d in ignore_dirs:
262 dirs.remove(d) 262 dirs.remove(d)
263 for f in files: 263 for f in files:
264 filename = [os.path.basename(client_path)] 264 filename = [os.path.basename(client_path)]
265 filename.extend(root[len(client_path) + 1:].split(os.path.sep)) 265 filename.extend(root[len(client_path) + 1:].split(os.path.sep))
266 filename.append(f) # Remove .lib or .app suffix. 266 filename.append(f) # Remove .lib or .app suffix.
267 test_path = current_path + filename 267 test_path = current_path + filename
268 test_dart_file = os.path.join(root, f) 268 test_dart_file = os.path.join(root, f)
269 if (not self.Contains(path, test_path) 269 if (not self.Contains(path, test_path)
270 or not self.IsTest(test_dart_file)): 270 or not self.IsTest(test_dart_file)):
271 continue 271 continue
272 tests.append(test_case.CompilationTestCase(test_path, 272 tests.append(test_case.CompilationTestCase(test_path,
273 self.context, 273 self.context,
274 test_dart_file, 274 test_dart_file,
275 mode, 275 mode,
276 arch)) 276 arch,
277 FOOBAR))
277 atexit.register(lambda: self._Cleanup(tests)) 278 atexit.register(lambda: self._Cleanup(tests))
278 return tests 279 return tests
279 280
280 def SourceDirs(self): 281 def SourceDirs(self):
281 """Returns a list of directories to scan for files to compile.""" 282 """Returns a list of directories to scan for files to compile."""
282 raise TestConfigurationError( 283 raise TestConfigurationError(
283 'Subclasses must implement SourceDirs()') 284 'Subclasses must implement SourceDirs()')
284 285
285 def IsTest(self, name): 286 def IsTest(self, name):
286 """Returns True if name is a test case to be compiled.""" 287 """Returns True if name is a test case to be compiled."""
(...skipping 11 matching lines...) Expand all
298 299
299 def GetTestStatus(self, sections, defs): 300 def GetTestStatus(self, sections, defs):
300 status = os.path.join(self.root, 'dartc.status') 301 status = os.path.join(self.root, 'dartc.status')
301 if os.path.exists(status): 302 if os.path.exists(status):
302 test.ReadConfigurationInto(status, sections, defs) 303 test.ReadConfigurationInto(status, sections, defs)
303 304
304 def _Cleanup(self, tests): 305 def _Cleanup(self, tests):
305 if not utils.Daemonize(): return 306 if not utils.Daemonize(): return
306 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]))
307 raise 308 raise
OLDNEW
« dart/tools/test.py ('K') | « dart/tools/testing/test_case.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698