| 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 // Find all relative imports and copy them into the dir that contains | 181 // Find all relative imports and copy them into the dir that contains |
| 182 // the generated tests. | 182 // the generated tests. |
| 183 Set<String> _findAllRelativeImports(Path topLibrary) { | 183 Set<String> _findAllRelativeImports(Path topLibrary) { |
| 184 Set<Path> toSearch = new Set<Path>.from([topLibrary]); | 184 Set<Path> toSearch = new Set<Path>.from([topLibrary]); |
| 185 Set<String> foundImports = new Set<String>(); | 185 Set<String> foundImports = new Set<String>(); |
| 186 Path libraryDir = topLibrary.directoryPath; | 186 Path libraryDir = topLibrary.directoryPath; |
| 187 RegExp relativeImportRegExp = new RegExp( | 187 RegExp relativeImportRegExp = new RegExp( |
| 188 '^(?:@.*\\s+)?' // Allow for a meta-data annotation. | 188 '^(?:@.*\\s+)?' // Allow for a meta-data annotation. |
| 189 '(import|part)' | 189 '(import|part)' |
| 190 '\\s+["\']' | 190 '\\s+["\']' |
| 191 '(?!(dart:|dart-ext:|package:|/))' // Look-ahead: not in package. | 191 '(?!(dart:|dart-ext:|data:|package:|/))' // Look-ahead: not in package. |
| 192 '([^"\']*)' // The path to the imported file. | 192 '([^"\']*)' // The path to the imported file. |
| 193 '["\']'); | 193 '["\']'); |
| 194 while (!toSearch.isEmpty) { | 194 while (!toSearch.isEmpty) { |
| 195 var thisPass = toSearch; | 195 var thisPass = toSearch; |
| 196 toSearch = new Set<Path>(); | 196 toSearch = new Set<Path>(); |
| 197 for (Path filename in thisPass) { | 197 for (Path filename in thisPass) { |
| 198 File f = new File(filename.toNativePath()); | 198 File f = new File(filename.toNativePath()); |
| 199 for (String line in f.readAsLinesSync()) { | 199 for (String line in f.readAsLinesSync()) { |
| 200 Match match = relativeImportRegExp.firstMatch(line); | 200 Match match = relativeImportRegExp.firstMatch(line); |
| 201 if (match != null) { | 201 if (match != null) { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 // TestSuite.forDirectory. | 301 // TestSuite.forDirectory. |
| 302 split.removeLast(); | 302 split.removeLast(); |
| 303 } | 303 } |
| 304 String path = '${generatedTestDir.path}/${split.last}'; | 304 String path = '${generatedTestDir.path}/${split.last}'; |
| 305 Directory dir = new Directory(path); | 305 Directory dir = new Directory(path); |
| 306 if (!dir.existsSync()) { | 306 if (!dir.existsSync()) { |
| 307 dir.createSync(); | 307 dir.createSync(); |
| 308 } | 308 } |
| 309 return new Path(new File(path).absolute.path); | 309 return new Path(new File(path).absolute.path); |
| 310 } | 310 } |
| OLD | NEW |