Chromium Code Reviews| 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 import "test_suite.dart"; | 9 import "test_suite.dart"; |
| 10 import "utils.dart"; | 10 import "utils.dart"; |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 // Copy all the relative imports of the multitest. | 241 // Copy all the relative imports of the multitest. |
| 242 Set<String> importsToCopy = _findAllRelativeImports(filePath); | 242 Set<String> importsToCopy = _findAllRelativeImports(filePath); |
| 243 List<Future> futureCopies = []; | 243 List<Future> futureCopies = []; |
| 244 for (String relativeImport in importsToCopy) { | 244 for (String relativeImport in importsToCopy) { |
| 245 Path importPath = new Path(relativeImport); | 245 Path importPath = new Path(relativeImport); |
| 246 // Make sure the target directory exists. | 246 // Make sure the target directory exists. |
| 247 Path importDir = importPath.directoryPath; | 247 Path importDir = importPath.directoryPath; |
| 248 if (!importDir.isEmpty) { | 248 if (!importDir.isEmpty) { |
| 249 TestUtils.mkdirRecursive(targetDir, importDir); | 249 TestUtils.mkdirRecursive(targetDir, importDir); |
| 250 } | 250 } |
| 251 Path srcPath = sourceDir.join(importPath); | |
| 252 Path targetPath = targetDir.join(importPath); | |
| 251 // Copy file. | 253 // Copy file. |
| 252 futureCopies.add(TestUtils.copyFile(sourceDir.join(importPath), | 254 Future copy = TestUtils.isContentEqual(srcPath, targetPath).then((equal) { |
|
Bill Hesse
2014/04/29 17:51:55
It seems to me that "copyIfDifferent" is a useful
ricow1
2014/04/30 06:51:01
Done.
| |
| 253 targetDir.join(importPath))); | 255 return equal ? null : TestUtils.copyFile(srcPath, targetPath); |
| 256 }); | |
| 257 futureCopies.add(copy); | |
| 254 } | 258 } |
| 255 | 259 |
| 256 // Wait until all imports are copied before scheduling test cases. | 260 // Wait until all imports are copied before scheduling test cases. |
| 257 return Future.wait(futureCopies).then((_) { | 261 return Future.wait(futureCopies).then((_) { |
| 258 String baseFilename = filePath.filenameWithoutExtension; | 262 String baseFilename = filePath.filenameWithoutExtension; |
| 259 for (String key in tests.keys) { | 263 for (String key in tests.keys) { |
| 260 final Path multitestFilename = | 264 final Path multitestFilename = |
| 261 targetDir.append('${baseFilename}_$key.dart'); | 265 targetDir.append('${baseFilename}_$key.dart'); |
| 262 writeFile(multitestFilename.toNativePath(), tests[key]); | 266 writeFile(multitestFilename.toNativePath(), tests[key]); |
| 263 Set<String> outcome = outcomes[key]; | 267 Set<String> outcome = outcomes[key]; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 296 // TestSuite.forDirectory. | 300 // TestSuite.forDirectory. |
| 297 split.removeLast(); | 301 split.removeLast(); |
| 298 } | 302 } |
| 299 String path = '${generatedTestDir.path}/${split.last}'; | 303 String path = '${generatedTestDir.path}/${split.last}'; |
| 300 Directory dir = new Directory(path); | 304 Directory dir = new Directory(path); |
| 301 if (!dir.existsSync()) { | 305 if (!dir.existsSync()) { |
| 302 dir.createSync(); | 306 dir.createSync(); |
| 303 } | 307 } |
| 304 return new Path(new File(path).absolute.path); | 308 return new Path(new File(path).absolute.path); |
| 305 } | 309 } |
| OLD | NEW |