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

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

Issue 12431020: Reapply "Update the test runner to use the new dart:io API" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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
« no previous file with comments | « tools/testing/dart/http_server.dart ('k') | tools/testing/dart/status_file_parser.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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: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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 class _Annotation { 130 class _Annotation {
131 String key; 131 String key;
132 String rest; 132 String rest;
133 List<String> outcomesList; 133 List<String> outcomesList;
134 _Annotation() {} 134 _Annotation() {}
135 factory _Annotation.from(String line) { 135 factory _Annotation.from(String line) {
136 if (!line.contains('///')) { 136 if (!line.contains('///')) {
137 return null; 137 return null;
138 } 138 }
139 var annotation = new _Annotation(); 139 var annotation = new _Annotation();
140 var parts = line.split('///')[1].split(':') 140 var parts = line.split('///')[1].split(':').map((s) => s.trim()).toList();
141 .mappedBy((s) => s.trim()).toList();
142 annotation.key = parts[0]; 141 annotation.key = parts[0];
143 annotation.rest = parts[1]; 142 annotation.rest = parts[1];
144 annotation.outcomesList = annotation.rest.split(',') 143 annotation.outcomesList = annotation.rest.split(',')
145 .mappedBy((s) => s.trim()).toList(); 144 .map((s) => s.trim()).toList();
146 return annotation; 145 return annotation;
147 } 146 }
148 } 147 }
149 148
150 // Find all relative imports and copy them into the dir that contains 149 // Find all relative imports and copy them into the dir that contains
151 // the generated tests. 150 // the generated tests.
152 Set<Path> _findAllRelativeImports(Path topLibrary) { 151 Set<Path> _findAllRelativeImports(Path topLibrary) {
153 Set<Path> toSearch = new Set<Path>.from([topLibrary]); 152 Set<Path> toSearch = new Set<Path>.from([topLibrary]);
154 Set<Path> foundImports = new HashSet<Path>(); 153 Set<Path> foundImports = new Set<Path>();
155 Path libraryDir = topLibrary.directoryPath; 154 Path libraryDir = topLibrary.directoryPath;
156 // Matches #import( or #source( followed by " or ' followed by anything 155 // Matches #import( or #source( followed by " or ' followed by anything
157 // except dart:, dart-ext: or /, at the beginning of a line. 156 // except dart:, dart-ext: or /, at the beginning of a line.
158 RegExp relativeImportRegExp = new RegExp( 157 RegExp relativeImportRegExp = new RegExp(
159 '^#(import|source)[(]["\'](?!(dart:|dart-ext:|/))([^"\']*)["\']'); 158 '^#(import|source)[(]["\'](?!(dart:|dart-ext:|/))([^"\']*)["\']');
160 while (!toSearch.isEmpty) { 159 while (!toSearch.isEmpty) {
161 var thisPass = toSearch; 160 var thisPass = toSearch;
162 toSearch = new HashSet<Path>(); 161 toSearch = new Set<Path>();
163 for (Path filename in thisPass) { 162 for (Path filename in thisPass) {
164 File f = new File.fromPath(filename); 163 File f = new File.fromPath(filename);
165 for (String line in f.readAsLinesSync()) { 164 for (String line in f.readAsLinesSync()) {
166 Match match = relativeImportRegExp.firstMatch(line); 165 Match match = relativeImportRegExp.firstMatch(line);
167 if (match != null) { 166 if (match != null) {
168 Path relativePath = new Path(match.group(3)); 167 Path relativePath = new Path(match.group(3));
169 if (foundImports.contains(relativePath)) { 168 if (foundImports.contains(relativePath)) {
170 continue; 169 continue;
171 } 170 }
172 if (relativePath.toString().contains('..')) { 171 if (relativePath.toString().contains('..')) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 // Wait until all imports are copied before scheduling test cases. 211 // Wait until all imports are copied before scheduling test cases.
213 return Future.wait(futureCopies).then((_) { 212 return Future.wait(futureCopies).then((_) {
214 String baseFilename = filePath.filenameWithoutExtension; 213 String baseFilename = filePath.filenameWithoutExtension;
215 for (String key in tests.keys) { 214 for (String key in tests.keys) {
216 final Path multitestFilename = 215 final Path multitestFilename =
217 targetDir.append('${baseFilename}_$key.dart'); 216 targetDir.append('${baseFilename}_$key.dart');
218 final File file = new File.fromPath(multitestFilename); 217 final File file = new File.fromPath(multitestFilename);
219 218
220 file.createSync(); 219 file.createSync();
221 RandomAccessFile openedFile = file.openSync(FileMode.WRITE); 220 RandomAccessFile openedFile = file.openSync(FileMode.WRITE);
222 var bytes = tests[key].charCodes; 221 openedFile.writeStringSync(tests[key]);
223 openedFile.writeListSync(bytes, 0, bytes.length);
224 openedFile.closeSync(); 222 openedFile.closeSync();
225 Set<String> outcome = outcomes[key]; 223 Set<String> outcome = outcomes[key];
226 bool enableFatalTypeErrors = outcome.contains('static type warning'); 224 bool enableFatalTypeErrors = outcome.contains('static type warning');
227 bool hasRuntimeErrors = outcome.contains('runtime error'); 225 bool hasRuntimeErrors = outcome.contains('runtime error');
228 bool hasCompileError = outcome.contains('compile-time error'); 226 bool hasCompileError = outcome.contains('compile-time error');
229 bool isNegativeIfChecked = outcome.contains('dynamic type error'); 227 bool isNegativeIfChecked = outcome.contains('dynamic type error');
230 doTest(multitestFilename, 228 doTest(multitestFilename,
231 hasCompileError, 229 hasCompileError,
232 hasRuntimeErrors, 230 hasRuntimeErrors,
233 isNegativeIfChecked: isNegativeIfChecked, 231 isNegativeIfChecked: isNegativeIfChecked,
(...skipping 21 matching lines...) Expand all
255 // TestSuite.forDirectory. 253 // TestSuite.forDirectory.
256 split.removeLast(); 254 split.removeLast();
257 } 255 }
258 String path = '${generatedTestDir.path}/${split.last}'; 256 String path = '${generatedTestDir.path}/${split.last}';
259 Directory dir = new Directory(path); 257 Directory dir = new Directory(path);
260 if (!dir.existsSync()) { 258 if (!dir.existsSync()) {
261 dir.createSync(); 259 dir.createSync();
262 } 260 }
263 return new Path(new File(path).fullPathSync()); 261 return new Path(new File(path).fullPathSync());
264 } 262 }
OLDNEW
« no previous file with comments | « tools/testing/dart/http_server.dart ('k') | tools/testing/dart/status_file_parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698