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:io"); | 7 #import("dart:io"); |
8 #import("test_suite.dart"); | 8 #import("test_suite.dart"); |
9 | 9 |
10 // Multitests are Dart test scripts containing lines of the form | 10 // Multitests are Dart test scripts containing lines of the form |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 } | 152 } |
153 | 153 |
154 // Find all relative imports and copy them into the dir that contains | 154 // Find all relative imports and copy them into the dir that contains |
155 // the generated tests. | 155 // the generated tests. |
156 Set<Path> _findAllRelativeImports(Path topLibrary) { | 156 Set<Path> _findAllRelativeImports(Path topLibrary) { |
157 Set<Path> toSearch = new Set<Path>.from([topLibrary]); | 157 Set<Path> toSearch = new Set<Path>.from([topLibrary]); |
158 Set<Path> foundImports = new HashSet<Path>(); | 158 Set<Path> foundImports = new HashSet<Path>(); |
159 Path libraryDir = topLibrary.directoryPath; | 159 Path libraryDir = topLibrary.directoryPath; |
160 // Matches #import( or #source( followed by " or ' followed by anything | 160 // Matches #import( or #source( followed by " or ' followed by anything |
161 // except dart:, dart-ext: or /, at the beginning of a line. | 161 // except dart:, dart-ext: or /, at the beginning of a line. |
162 RegExp relativeImportRegExp = new RegExp( | 162 RegExp relativeImportRegExp = const RegExp( |
163 '^#(import|source)[(]["\'](?!(dart:|dart-ext:|/))([^"\']*)["\']'); | 163 '^#(import|source)[(]["\'](?!(dart:|dart-ext:|/))([^"\']*)["\']'); |
164 while (!toSearch.isEmpty) { | 164 while (!toSearch.isEmpty) { |
165 var thisPass = toSearch; | 165 var thisPass = toSearch; |
166 toSearch = new HashSet<Path>(); | 166 toSearch = new HashSet<Path>(); |
167 for (Path filename in thisPass) { | 167 for (Path filename in thisPass) { |
168 File f = new File.fromPath(filename); | 168 File f = new File.fromPath(filename); |
169 for (String line in f.readAsLinesSync()) { | 169 for (String line in f.readAsLinesSync()) { |
170 Match match = relativeImportRegExp.firstMatch(line); | 170 Match match = relativeImportRegExp.firstMatch(line); |
171 if (match != null) { | 171 if (match != null) { |
172 Path relativePath = new Path(match.group(3)); | 172 Path relativePath = new Path(match.group(3)); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 // TestSuite.forDirectory. | 259 // TestSuite.forDirectory. |
260 split.removeLast(); | 260 split.removeLast(); |
261 } | 261 } |
262 String path = '${generatedTestDir.path}/${split.last}'; | 262 String path = '${generatedTestDir.path}/${split.last}'; |
263 Directory dir = new Directory(path); | 263 Directory dir = new Directory(path); |
264 if (!dir.existsSync()) { | 264 if (!dir.existsSync()) { |
265 dir.createSync(); | 265 dir.createSync(); |
266 } | 266 } |
267 return new Path.fromNative(new File(path).fullPathSync()); | 267 return new Path.fromNative(new File(path).fullPathSync()); |
268 } | 268 } |
OLD | NEW |