Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: tools/testing/dart/multitest.dart

Issue 11817012: Migration of testing scripts in tools/ to libv2 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: added binaries Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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:io"; 8 import "dart:io";
8 import "test_suite.dart"; 9 import "test_suite.dart";
9 10
10 // Multitests are Dart test scripts containing lines of the form 11 // Multitests are Dart test scripts containing lines of the form
11 // " [some dart code] /// [key]: [error type]" 12 // " [some dart code] /// [key]: [error type]"
12 // 13 //
13 // For each key in the file, a new test file is made containing all 14 // For each key in the file, a new test file is made containing all
14 // the normal lines of the file, and all of the multitest lines containing 15 // the normal lines of the file, and all of the multitest lines containing
15 // that key, in the same order as in the source file. The new test 16 // that key, in the same order as in the source file. The new test
16 // is expected to fail if there is a non-empty error type listed, of 17 // is expected to fail if there is a non-empty error type listed, of
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 class _Annotation { 136 class _Annotation {
136 String key; 137 String key;
137 String rest; 138 String rest;
138 List<String> outcomesList; 139 List<String> outcomesList;
139 _Annotation() {} 140 _Annotation() {}
140 factory _Annotation.from(String line) { 141 factory _Annotation.from(String line) {
141 if (!line.contains('///')) { 142 if (!line.contains('///')) {
142 return null; 143 return null;
143 } 144 }
144 var annotation = new _Annotation(); 145 var annotation = new _Annotation();
145 var parts = line.split('///')[1].split(':').map((s) => s.trim()); 146 var parts = line.split('///')[1].split(':').mappedBy((s) => s.trim());
Bill Hesse 2013/01/09 17:06:33 This returns an iterable, so either use the iterab
kustermann 2013/01/09 18:02:25 Done.
146 annotation.key = parts[0]; 147 annotation.key = parts[0];
147 annotation.rest = parts[1]; 148 annotation.rest = parts[1];
148 annotation.outcomesList = annotation.rest.split(',') 149 annotation.outcomesList = annotation.rest.split(',')
149 .map((s) => s.trim()); 150 .mappedBy((s) => s.trim());
150 return annotation; 151 return annotation;
Bill Hesse 2013/01/09 17:06:33 toList.
kustermann 2013/01/09 18:02:25 Done.
151 } 152 }
152 } 153 }
153 154
154 // Find all relative imports and copy them into the dir that contains 155 // Find all relative imports and copy them into the dir that contains
155 // the generated tests. 156 // the generated tests.
156 Set<Path> _findAllRelativeImports(Path topLibrary) { 157 Set<Path> _findAllRelativeImports(Path topLibrary) {
157 Set<Path> toSearch = new Set<Path>.from([topLibrary]); 158 Set<Path> toSearch = new Set<Path>.from([topLibrary]);
158 Set<Path> foundImports = new HashSet<Path>(); 159 Set<Path> foundImports = new HashSet<Path>();
159 Path libraryDir = topLibrary.directoryPath; 160 Path libraryDir = topLibrary.directoryPath;
160 // Matches #import( or #source( followed by " or ' followed by anything 161 // Matches #import( or #source( followed by " or ' followed by anything
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 Path importDir = importPath.directoryPath; 208 Path importDir = importPath.directoryPath;
208 if (!importDir.isEmpty) { 209 if (!importDir.isEmpty) {
209 TestUtils.mkdirRecursive(targetDir, importDir); 210 TestUtils.mkdirRecursive(targetDir, importDir);
210 } 211 }
211 // Copy file. 212 // Copy file.
212 futureCopies.add(TestUtils.copyFile(sourceDir.join(importPath), 213 futureCopies.add(TestUtils.copyFile(sourceDir.join(importPath),
213 targetDir.join(importPath))); 214 targetDir.join(importPath)));
214 } 215 }
215 216
216 // Wait until all imports are copied before scheduling test cases. 217 // Wait until all imports are copied before scheduling test cases.
217 return Futures.wait(futureCopies).transform((_) { 218 return Futures.wait(futureCopies).then((_) {
218 String baseFilename = filePath.filenameWithoutExtension; 219 String baseFilename = filePath.filenameWithoutExtension;
219 for (String key in tests.keys) { 220 for (String key in tests.keys) {
220 final Path multitestFilename = 221 final Path multitestFilename =
221 targetDir.append('${baseFilename}_$key.dart'); 222 targetDir.append('${baseFilename}_$key.dart');
222 final File file = new File.fromPath(multitestFilename); 223 final File file = new File.fromPath(multitestFilename);
223 224
224 file.createSync(); 225 file.createSync();
225 RandomAccessFile openedFile = file.openSync(FileMode.WRITE); 226 RandomAccessFile openedFile = file.openSync(FileMode.WRITE);
226 var bytes = tests[key].charCodes; 227 var bytes = tests[key].charCodes;
227 openedFile.writeListSync(bytes, 0, bytes.length); 228 openedFile.writeListSync(bytes, 0, bytes.length);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 // TestSuite.forDirectory. 260 // TestSuite.forDirectory.
260 split.removeLast(); 261 split.removeLast();
261 } 262 }
262 String path = '${generatedTestDir.path}/${split.last}'; 263 String path = '${generatedTestDir.path}/${split.last}';
263 Directory dir = new Directory(path); 264 Directory dir = new Directory(path);
264 if (!dir.existsSync()) { 265 if (!dir.existsSync()) {
265 dir.createSync(); 266 dir.createSync();
266 } 267 }
267 return new Path.fromNative(new File(path).fullPathSync()); 268 return new Path.fromNative(new File(path).fullPathSync());
268 } 269 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698