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

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: 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(':')
147 .mappedBy((s) => s.trim()).toList();
146 annotation.key = parts[0]; 148 annotation.key = parts[0];
147 annotation.rest = parts[1]; 149 annotation.rest = parts[1];
148 annotation.outcomesList = annotation.rest.split(',') 150 annotation.outcomesList = annotation.rest.split(',')
149 .map((s) => s.trim()); 151 .mappedBy((s) => s.trim()).toList();
150 return annotation; 152 return annotation;
151 } 153 }
152 } 154 }
153 155
154 // Find all relative imports and copy them into the dir that contains 156 // Find all relative imports and copy them into the dir that contains
155 // the generated tests. 157 // the generated tests.
156 Set<Path> _findAllRelativeImports(Path topLibrary) { 158 Set<Path> _findAllRelativeImports(Path topLibrary) {
157 Set<Path> toSearch = new Set<Path>.from([topLibrary]); 159 Set<Path> toSearch = new Set<Path>.from([topLibrary]);
158 Set<Path> foundImports = new HashSet<Path>(); 160 Set<Path> foundImports = new HashSet<Path>();
159 Path libraryDir = topLibrary.directoryPath; 161 Path libraryDir = topLibrary.directoryPath;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 Path importDir = importPath.directoryPath; 209 Path importDir = importPath.directoryPath;
208 if (!importDir.isEmpty) { 210 if (!importDir.isEmpty) {
209 TestUtils.mkdirRecursive(targetDir, importDir); 211 TestUtils.mkdirRecursive(targetDir, importDir);
210 } 212 }
211 // Copy file. 213 // Copy file.
212 futureCopies.add(TestUtils.copyFile(sourceDir.join(importPath), 214 futureCopies.add(TestUtils.copyFile(sourceDir.join(importPath),
213 targetDir.join(importPath))); 215 targetDir.join(importPath)));
214 } 216 }
215 217
216 // Wait until all imports are copied before scheduling test cases. 218 // Wait until all imports are copied before scheduling test cases.
217 return Futures.wait(futureCopies).transform((_) { 219 return Futures.wait(futureCopies).then((_) {
218 String baseFilename = filePath.filenameWithoutExtension; 220 String baseFilename = filePath.filenameWithoutExtension;
219 for (String key in tests.keys) { 221 for (String key in tests.keys) {
220 final Path multitestFilename = 222 final Path multitestFilename =
221 targetDir.append('${baseFilename}_$key.dart'); 223 targetDir.append('${baseFilename}_$key.dart');
222 final File file = new File.fromPath(multitestFilename); 224 final File file = new File.fromPath(multitestFilename);
223 225
224 file.createSync(); 226 file.createSync();
225 RandomAccessFile openedFile = file.openSync(FileMode.WRITE); 227 RandomAccessFile openedFile = file.openSync(FileMode.WRITE);
226 var bytes = tests[key].charCodes; 228 var bytes = tests[key].charCodes;
227 openedFile.writeListSync(bytes, 0, bytes.length); 229 openedFile.writeListSync(bytes, 0, bytes.length);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 // TestSuite.forDirectory. 261 // TestSuite.forDirectory.
260 split.removeLast(); 262 split.removeLast();
261 } 263 }
262 String path = '${generatedTestDir.path}/${split.last}'; 264 String path = '${generatedTestDir.path}/${split.last}';
263 Directory dir = new Directory(path); 265 Directory dir = new Directory(path);
264 if (!dir.existsSync()) { 266 if (!dir.existsSync()) {
265 dir.createSync(); 267 dir.createSync();
266 } 268 }
267 return new Path.fromNative(new File(path).fullPathSync()); 269 return new Path.fromNative(new File(path).fullPathSync());
268 } 270 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698