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

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
« no previous file with comments | « 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, component):
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 component 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, component,
78 options))
78 return tests 79 return tests
79 else: 80 else:
80 return [test_case.BrowserTestCase( 81 return [test_case.BrowserTestCase(
81 self.context, test_path, filename, False, mode, arch)] 82 self.context, test_path, filename, False, mode, arch, component)]
82 else: 83 else:
83 tests = [] 84 tests = []
84 if tags: 85 if tags:
85 for tag in sorted(tags): 86 for tag in sorted(tags):
86 kind, test_source = tags[tag] 87 kind, test_source = tags[tag]
87 if not self.Contains(path, test_path + [tag]): 88 if not self.Contains(path, test_path + [tag]):
88 continue 89 continue
89 tests.append(test_case.MultiTestCase(self.context, 90 tests.append(test_case.MultiTestCase(self.context,
90 test_path + [tag], 91 test_path + [tag],
91 test_source, 92 test_source,
92 kind, 93 kind,
93 mode, arch)) 94 mode, arch, component))
94 else: 95 else:
95 if vm_options_list: 96 if vm_options_list:
96 for options in vm_options_list: 97 for options in vm_options_list:
97 tests.append(test_case.StandardTestCase(self.context, 98 tests.append(test_case.StandardTestCase(self.context,
98 test_path, filename, mode, arch, options)) 99 test_path, filename, mode, arch, component, options))
99 else: 100 else:
100 tests.append(test_case.StandardTestCase(self.context, 101 tests.append(test_case.StandardTestCase(self.context,
101 test_path, filename, mode, arch)) 102 test_path, filename, mode, arch, component))
102 return tests 103 return tests
103 104
104 def ListTests(self, current_path, path, mode, arch): 105 def ListTests(self, current_path, path, mode, arch, component):
105 """Searches for *Test.dart files and returns list of TestCases.""" 106 """Searches for *Test.dart files and returns list of TestCases."""
106 tests = [] 107 tests = []
107 for root, unused_dirs, files in os.walk(os.path.join(self.root, 'src')): 108 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)]: 109 for f in [x for x in files if self.IsTest(x)]:
109 if f.endswith('.dart'): 110 if f.endswith('.dart'):
110 test_path = current_path + [f[:-5]] # Remove .dart suffix. 111 test_path = current_path + [f[:-5]] # Remove .dart suffix.
111 elif f.endswith('.app'): 112 elif f.endswith('.app'):
112 # TODO(zundel): .app files are used only the dromaeo test 113 # TODO(zundel): .app files are used only the dromaeo test
113 # and should be removed. 114 # and should be removed.
114 test_path = current_path + [f[:-4]] # Remove .app suffix. 115 test_path = current_path + [f[:-4]] # Remove .app suffix.
115 if not self.Contains(path, test_path): 116 if not self.Contains(path, test_path):
116 continue 117 continue
117 tests.extend(self.CreateTestCases(test_path, path, 118 tests.extend(self.CreateTestCases(test_path, path,
118 os.path.join(root, f), 119 os.path.join(root, f),
119 mode, arch)) 120 mode, arch, component))
120 atexit.register(lambda: self._Cleanup(tests)) 121 atexit.register(lambda: self._Cleanup(tests))
121 return tests 122 return tests
122 123
123 def IsTest(self, name): 124 def IsTest(self, name):
124 """Returns True if the file name is a test file.""" 125 """Returns True if the file name is a test file."""
125 return name.endswith('Test.dart') or name.endswith('Test.app') 126 return name.endswith('Test.dart') or name.endswith('Test.app')
126 127
127 def GetTestStatus(self, sections, defs): 128 def GetTestStatus(self, sections, defs):
128 """Reads the .status file of the TestSuite.""" 129 """Reads the .status file of the TestSuite."""
129 status = os.path.join(self.root, os.path.basename(self.root) + '.status') 130 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 214 return tests
214 215
215 216
216 class BrowserTestConfiguration(StandardTestConfiguration): 217 class BrowserTestConfiguration(StandardTestConfiguration):
217 """A configuration used to run tests inside a browser.""" 218 """A configuration used to run tests inside a browser."""
218 219
219 def __init__(self, context, root, fatal_static_type_errors=False): 220 def __init__(self, context, root, fatal_static_type_errors=False):
220 super(BrowserTestConfiguration, self).__init__(context, root) 221 super(BrowserTestConfiguration, self).__init__(context, root)
221 self.fatal_static_type_errors = fatal_static_type_errors 222 self.fatal_static_type_errors = fatal_static_type_errors
222 223
223 def ListTests(self, current_path, path, mode, arch): 224 def ListTests(self, current_path, path, mode, arch, component):
224 """Searches for *Test .dart files and returns list of TestCases.""" 225 """Searches for *Test .dart files and returns list of TestCases."""
225 tests = [] 226 tests = []
226 for root, unused_dirs, files in os.walk(self.root): 227 for root, unused_dirs, files in os.walk(self.root):
227 for f in [x for x in files if self.IsTest(x)]: 228 for f in [x for x in files if self.IsTest(x)]:
228 relative = os.path.relpath(root, self.root).split(os.path.sep) 229 relative = os.path.relpath(root, self.root).split(os.path.sep)
229 test_path = current_path + relative + [os.path.splitext(f)[0]] 230 test_path = current_path + relative + [os.path.splitext(f)[0]]
230 if not self.Contains(path, test_path): 231 if not self.Contains(path, test_path):
231 continue 232 continue
232 tests.append(test_case.BrowserTestCase(self.context, 233 tests.append(test_case.BrowserTestCase(self.context,
233 test_path, 234 test_path,
234 os.path.join(root, f), 235 os.path.join(root, f),
235 self.fatal_static_type_errors, 236 self.fatal_static_type_errors,
236 mode, arch)) 237 mode, arch, component))
237 atexit.register(lambda: self._Cleanup(tests)) 238 atexit.register(lambda: self._Cleanup(tests))
238 return tests 239 return tests
239 240
240 def IsTest(self, name): 241 def IsTest(self, name):
241 return name.endswith('_tests.dart') 242 return name.endswith('_tests.dart')
242 243
243 244
244 class CompilationTestConfiguration(test.TestConfiguration): 245 class CompilationTestConfiguration(test.TestConfiguration):
245 """Configuration that searches specific directories for apps to compile. 246 """Configuration that searches specific directories for apps to compile.
246 247
247 Expects a status file named dartc.status 248 Expects a status file named dartc.status
248 """ 249 """
249 250
250 def __init__(self, context, root): 251 def __init__(self, context, root):
251 super(CompilationTestConfiguration, self).__init__(context, root) 252 super(CompilationTestConfiguration, self).__init__(context, root)
252 253
253 def ListTests(self, current_path, path, mode, arch): 254 def ListTests(self, current_path, path, mode, arch, component):
254 """Searches for *Test.dart files and returns list of TestCases.""" 255 """Searches for *Test.dart files and returns list of TestCases."""
255 tests = [] 256 tests = []
256 client_path = os.path.normpath(os.path.join(self.root, '..', '..')) 257 client_path = os.path.normpath(os.path.join(self.root, '..', '..'))
257 258
258 for src_dir in self.SourceDirs(): 259 for src_dir in self.SourceDirs():
259 for root, dirs, files in os.walk(os.path.join(client_path, src_dir)): 260 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('.')] 261 ignore_dirs = [d for d in dirs if d.startswith('.')]
261 for d in ignore_dirs: 262 for d in ignore_dirs:
262 dirs.remove(d) 263 dirs.remove(d)
263 for f in files: 264 for f in files:
264 filename = [os.path.basename(client_path)] 265 filename = [os.path.basename(client_path)]
265 filename.extend(root[len(client_path) + 1:].split(os.path.sep)) 266 filename.extend(root[len(client_path) + 1:].split(os.path.sep))
266 filename.append(f) # Remove .lib or .app suffix. 267 filename.append(f) # Remove .lib or .app suffix.
267 test_path = current_path + filename 268 test_path = current_path + filename
268 test_dart_file = os.path.join(root, f) 269 test_dart_file = os.path.join(root, f)
269 if (not self.Contains(path, test_path) 270 if (not self.Contains(path, test_path)
270 or not self.IsTest(test_dart_file)): 271 or not self.IsTest(test_dart_file)):
271 continue 272 continue
272 tests.append(test_case.CompilationTestCase(test_path, 273 tests.append(test_case.CompilationTestCase(test_path,
273 self.context, 274 self.context,
274 test_dart_file, 275 test_dart_file,
275 mode, 276 mode,
276 arch)) 277 arch,
278 component))
277 atexit.register(lambda: self._Cleanup(tests)) 279 atexit.register(lambda: self._Cleanup(tests))
278 return tests 280 return tests
279 281
280 def SourceDirs(self): 282 def SourceDirs(self):
281 """Returns a list of directories to scan for files to compile.""" 283 """Returns a list of directories to scan for files to compile."""
282 raise TestConfigurationError( 284 raise TestConfigurationError(
283 'Subclasses must implement SourceDirs()') 285 'Subclasses must implement SourceDirs()')
284 286
285 def IsTest(self, name): 287 def IsTest(self, name):
286 """Returns True if name is a test case to be compiled.""" 288 """Returns True if name is a test case to be compiled."""
(...skipping 11 matching lines...) Expand all
298 300
299 def GetTestStatus(self, sections, defs): 301 def GetTestStatus(self, sections, defs):
300 status = os.path.join(self.root, 'dartc.status') 302 status = os.path.join(self.root, 'dartc.status')
301 if os.path.exists(status): 303 if os.path.exists(status):
302 test.ReadConfigurationInto(status, sections, defs) 304 test.ReadConfigurationInto(status, sections, defs)
303 305
304 def _Cleanup(self, tests): 306 def _Cleanup(self, tests):
305 if not utils.Daemonize(): return 307 if not utils.Daemonize(): return
306 os.execlp('rm', *(['rm', '-rf'] + [t.temp_dir for t in tests])) 308 os.execlp('rm', *(['rm', '-rf'] + [t.temp_dir for t in tests]))
307 raise 309 raise
OLDNEW
« no previous file with comments | « dart/tools/testing/test_case.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698