| 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 | 174 |
| 175 // Find all relative imports and copy them into the dir that contains | 175 // Find all relative imports and copy them into the dir that contains |
| 176 // the generated tests. | 176 // the generated tests. |
| 177 Set<String> _findAllRelativeImports(Path topLibrary) { | 177 Set<String> _findAllRelativeImports(Path topLibrary) { |
| 178 Set<Path> toSearch = new Set<Path>.from([topLibrary]); | 178 Set<Path> toSearch = new Set<Path>.from([topLibrary]); |
| 179 Set<String> foundImports = new Set<String>(); | 179 Set<String> foundImports = new Set<String>(); |
| 180 Path libraryDir = topLibrary.directoryPath; | 180 Path libraryDir = topLibrary.directoryPath; |
| 181 RegExp relativeImportRegExp = new RegExp( | 181 RegExp relativeImportRegExp = new RegExp( |
| 182 '^(import|part)\\s+["\'](?!(dart:|dart-ext:|package:|/))([^"\']*)["\']'); | 182 '^(?:@.*\\s+)?' // Allow for a meta-data annotation. |
| 183 '(import|part)' |
| 184 '\\s+["\']' |
| 185 '(?!(dart:|dart-ext:|package:|/))' // Look-ahead: not in package. |
| 186 '([^"\']*)' // The path to the imported file. |
| 187 '["\']'); |
| 183 while (!toSearch.isEmpty) { | 188 while (!toSearch.isEmpty) { |
| 184 var thisPass = toSearch; | 189 var thisPass = toSearch; |
| 185 toSearch = new Set<Path>(); | 190 toSearch = new Set<Path>(); |
| 186 for (Path filename in thisPass) { | 191 for (Path filename in thisPass) { |
| 187 File f = new File(filename.toNativePath()); | 192 File f = new File(filename.toNativePath()); |
| 188 for (String line in f.readAsLinesSync()) { | 193 for (String line in f.readAsLinesSync()) { |
| 189 Match match = relativeImportRegExp.firstMatch(line); | 194 Match match = relativeImportRegExp.firstMatch(line); |
| 190 if (match != null) { | 195 if (match != null) { |
| 191 Path relativePath = new Path(match.group(3)); | 196 Path relativePath = new Path(match.group(3)); |
| 192 if (foundImports.contains(relativePath.toString())) { | 197 if (foundImports.contains(relativePath.toString())) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 // TestSuite.forDirectory. | 294 // TestSuite.forDirectory. |
| 290 split.removeLast(); | 295 split.removeLast(); |
| 291 } | 296 } |
| 292 String path = '${generatedTestDir.path}/${split.last}'; | 297 String path = '${generatedTestDir.path}/${split.last}'; |
| 293 Directory dir = new Directory(path); | 298 Directory dir = new Directory(path); |
| 294 if (!dir.existsSync()) { | 299 if (!dir.existsSync()) { |
| 295 dir.createSync(); | 300 dir.createSync(); |
| 296 } | 301 } |
| 297 return new Path(new File(path).absolute.path); | 302 return new Path(new File(path).absolute.path); |
| 298 } | 303 } |
| OLD | NEW |