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

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

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