OLD | NEW |
1 // Copyright (c) 2011, 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 |
11 // " [some dart code] /// [key]: [error type]" | 11 // " [some dart code] /// [key]: [error type]" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 .map((s) => s.trim()); | 148 .map((s) => s.trim()); |
149 return annotation; | 149 return annotation; |
150 } | 150 } |
151 } | 151 } |
152 | 152 |
153 // Find all relative imports and copy them into the dir that contains | 153 // Find all relative imports and copy them into the dir that contains |
154 // the generated tests. | 154 // the generated tests. |
155 Set<String> _findAllRelativeImports(String topLibrary) { | 155 Set<String> _findAllRelativeImports(String topLibrary) { |
156 Set<String> toSearch = new Set<String>.from([topLibrary]); | 156 Set<String> toSearch = new Set<String>.from([topLibrary]); |
157 Set<String> foundImports = new HashSet<String>(); | 157 Set<String> foundImports = new HashSet<String>(); |
158 String pathSep = new Platform().pathSeparator(); | 158 String pathSep = Platform.pathSeparator(); |
159 int end = topLibrary.lastIndexOf(pathSep); | 159 int end = topLibrary.lastIndexOf(pathSep); |
160 String libraryDir = topLibrary.substring(0, end); | 160 String libraryDir = topLibrary.substring(0, end); |
161 | 161 |
162 // Matches #import( or #source( followed by " or ' followed by anything | 162 // Matches #import( or #source( followed by " or ' followed by anything |
163 // except dart: or /, at the beginning of a line. | 163 // except dart: or /, at the beginning of a line. |
164 RegExp relativeImportRegExp = | 164 RegExp relativeImportRegExp = |
165 const RegExp('^#(import|source)[(]["\'](?!(dart:|/))([^"\']*)["\']'); | 165 const RegExp('^#(import|source)[(]["\'](?!(dart:|/))([^"\']*)["\']'); |
166 while (!toSearch.isEmpty()) { | 166 while (!toSearch.isEmpty()) { |
167 var thisPass = toSearch; | 167 var thisPass = toSearch; |
168 toSearch = new HashSet<String>(); | 168 toSearch = new HashSet<String>(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 bool hasRuntimeErrors, | 202 bool hasRuntimeErrors, |
203 Set<String> multitestOutcome]), | 203 Set<String> multitestOutcome]), |
204 Function multitestDone) { | 204 Function multitestDone) { |
205 // Each new test is a single String value in the Map tests. | 205 // Each new test is a single String value in the Map tests. |
206 Map<String, String> tests = new Map<String, String>(); | 206 Map<String, String> tests = new Map<String, String>(); |
207 Map<String, Set<String>> outcomes = new Map<String, Set<String>>(); | 207 Map<String, Set<String>> outcomes = new Map<String, Set<String>>(); |
208 ExtractTestsFromMultitest(filename, tests, outcomes); | 208 ExtractTestsFromMultitest(filename, tests, outcomes); |
209 | 209 |
210 String directory = CreateMultitestDirectory(outputDir, testDir); | 210 String directory = CreateMultitestDirectory(outputDir, testDir); |
211 Expect.isNotNull(directory); | 211 Expect.isNotNull(directory); |
212 String pathSep = new Platform().pathSeparator(); | 212 String pathSep = Platform.pathSeparator(); |
213 int start = filename.lastIndexOf(pathSep) + 1; | 213 int start = filename.lastIndexOf(pathSep) + 1; |
214 int end = filename.indexOf('.dart', start); | 214 int end = filename.indexOf('.dart', start); |
215 String baseFilename = filename.substring(start, end); | 215 String baseFilename = filename.substring(start, end); |
216 String sourceDirectory = filename.substring(0, start - 1); | 216 String sourceDirectory = filename.substring(0, start - 1); |
217 Set<String> importsToCopy = _findAllRelativeImports(filename); | 217 Set<String> importsToCopy = _findAllRelativeImports(filename); |
218 Directory destDir = new Directory("directory"); | 218 Directory destDir = new Directory("directory"); |
219 for (String import in importsToCopy) { | 219 for (String import in importsToCopy) { |
220 File source = new File('$sourceDirectory/$import'); | 220 File source = new File('$sourceDirectory/$import'); |
221 var dest = new File('$directory/$import'); | 221 var dest = new File('$directory/$import'); |
222 var basenameStart = import.lastIndexOf('/'); | 222 var basenameStart = import.lastIndexOf('/'); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 var split = testDir.split('/'); | 265 var split = testDir.split('/'); |
266 var lastComponent = split.removeLast(); | 266 var lastComponent = split.removeLast(); |
267 Expect.isTrue(lastComponent == 'src'); | 267 Expect.isTrue(lastComponent == 'src'); |
268 String path = '${generatedTestDir.path}/${split.last()}'; | 268 String path = '${generatedTestDir.path}/${split.last()}'; |
269 Directory dir = new Directory(path); | 269 Directory dir = new Directory(path); |
270 if (!dir.existsSync()) { | 270 if (!dir.existsSync()) { |
271 dir.createSync(); | 271 dir.createSync(); |
272 } | 272 } |
273 return path; | 273 return path; |
274 } | 274 } |
OLD | NEW |