OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 library multitest; | 5 library multitest; |
6 | 6 |
7 import "dart:async"; | 7 import "dart:async"; |
8 import "dart:io"; | 8 import "dart:io"; |
9 | 9 |
10 import "path.dart"; | 10 import "path.dart"; |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 } | 238 } |
239 file.writeAsStringSync(content); | 239 file.writeAsStringSync(content); |
240 } | 240 } |
241 | 241 |
242 // Each new test is a single String value in the Map tests. | 242 // Each new test is a single String value in the Map tests. |
243 Map<String, String> tests = new Map<String, String>(); | 243 Map<String, String> tests = new Map<String, String>(); |
244 Map<String, Set<String>> outcomes = new Map<String, Set<String>>(); | 244 Map<String, Set<String>> outcomes = new Map<String, Set<String>>(); |
245 ExtractTestsFromMultitest(filePath, tests, outcomes); | 245 ExtractTestsFromMultitest(filePath, tests, outcomes); |
246 | 246 |
247 Path sourceDir = filePath.directoryPath; | 247 Path sourceDir = filePath.directoryPath; |
248 Path targetDir = CreateMultitestDirectory(outputDir, suiteDir); | 248 Path targetDir = createMultitestDirectory(outputDir, suiteDir, sourceDir); |
249 assert(targetDir != null); | 249 assert(targetDir != null); |
250 | 250 |
251 // Copy all the relative imports of the multitest. | 251 // Copy all the relative imports of the multitest. |
252 Set<String> importsToCopy = _findAllRelativeImports(filePath); | 252 Set<String> importsToCopy = _findAllRelativeImports(filePath); |
253 List<Future> futureCopies = []; | 253 List<Future> futureCopies = []; |
254 for (String relativeImport in importsToCopy) { | 254 for (String relativeImport in importsToCopy) { |
255 Path importPath = new Path(relativeImport); | 255 Path importPath = new Path(relativeImport); |
256 // Make sure the target directory exists. | 256 // Make sure the target directory exists. |
257 Path importDir = importPath.directoryPath; | 257 Path importDir = importPath.directoryPath; |
258 if (!importDir.isEmpty) { | 258 if (!importDir.isEmpty) { |
(...skipping 29 matching lines...) Expand all Loading... |
288 isNegativeIfChecked: isNegativeIfChecked, | 288 isNegativeIfChecked: isNegativeIfChecked, |
289 hasCompileErrorIfChecked: hasCompileErrorIfChecked, | 289 hasCompileErrorIfChecked: hasCompileErrorIfChecked, |
290 hasStaticWarning: hasStaticWarning, | 290 hasStaticWarning: hasStaticWarning, |
291 multitestKey: key); | 291 multitestKey: key); |
292 } | 292 } |
293 | 293 |
294 return null; | 294 return null; |
295 }); | 295 }); |
296 } | 296 } |
297 | 297 |
298 Path CreateMultitestDirectory(String outputDir, Path suiteDir) { | 298 String suiteNameFromPath(Path suiteDir) { |
299 Directory generatedTestDir = new Directory('$outputDir/generated_tests'); | |
300 if (!new Directory(outputDir).existsSync()) { | |
301 new Directory(outputDir).createSync(); | |
302 } | |
303 if (!generatedTestDir.existsSync()) { | |
304 generatedTestDir.createSync(); | |
305 } | |
306 var split = suiteDir.segments(); | 299 var split = suiteDir.segments(); |
| 300 // co19 test suite is at tests/co19/src. |
307 if (split.last == 'src') { | 301 if (split.last == 'src') { |
308 // TODO(sigmund): remove this once all tests are migrated to use | |
309 // TestSuite.forDirectory. | |
310 split.removeLast(); | 302 split.removeLast(); |
311 } | 303 } |
312 String path = '${generatedTestDir.path}/${split.last}'; | 304 return split.last; |
313 Directory dir = new Directory(path); | |
314 if (!dir.existsSync()) { | |
315 dir.createSync(); | |
316 } | |
317 return new Path(new File(path).absolute.path); | |
318 } | 305 } |
| 306 |
| 307 Path createMultitestDirectory(String outputDir, Path suiteDir, Path sourceDir) { |
| 308 Path relative = sourceDir.relativeTo(suiteDir); |
| 309 Path path = new Path(outputDir).append('generated_tests') |
| 310 .append(suiteNameFromPath(suiteDir)).join(relative); |
| 311 TestUtils.mkdirRecursive(TestUtils.currentWorkingDirectory, path); |
| 312 return new Path(new File(path.toNativePath()).absolute.path); |
| 313 } |
OLD | NEW |