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

Side by Side Diff: pkg/front_end/lib/src/fasta/testing/kernel_chain.dart

Issue 2691613002: Improve compile-time error handling. (Closed)
Patch Set: Update status and expectations for rasta tests. Created 3 years, 10 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 // TODO(ahe): Copied from closure_conversion branch of kernel, remove this file 5 // TODO(ahe): Copied from closure_conversion branch of kernel, remove this file
6 // when closure_conversion is merged with master. 6 // when closure_conversion is merged with master.
7 7
8 library kernel.testing.kernel_chain; 8 library kernel.testing.kernel_chain;
9 9
10 import 'dart:async' show 10 import 'dart:async' show
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 ignoreRedirectingFactories: false, dartSdk: dartSdk); 148 ignoreRedirectingFactories: false, dartSdk: dartSdk);
149 } 149 }
150 150
151 static Future<TestContext> create(Chain suite, 151 static Future<TestContext> create(Chain suite,
152 Map<String, String> environment, 152 Map<String, String> environment,
153 TestContextConstructor constructor) async { 153 TestContextConstructor constructor) async {
154 Uri sdk = await computePatchedSdk(); 154 Uri sdk = await computePatchedSdk();
155 Uri vm = computeDartVm(sdk); 155 Uri vm = computeDartVm(sdk);
156 Uri packages = Uri.base.resolve(".packages"); 156 Uri packages = Uri.base.resolve(".packages");
157 bool strongMode = false; 157 bool strongMode = false;
158 bool updateExpectations = environment["updateExpectations"] != "false"; 158 bool updateExpectations = environment["updateExpectations"] == "true";
159 return constructor(suite, environment, sdk, vm, packages, strongMode, 159 return constructor(suite, environment, sdk, vm, packages, strongMode,
160 createDartSdk(sdk.toFilePath(), strongMode: strongMode), 160 createDartSdk(sdk.toFilePath(), strongMode: strongMode),
161 updateExpectations); 161 updateExpectations);
162 } 162 }
163 } 163 }
164 164
165 class Kernel extends Step<TestDescription, Program, TestContext> { 165 class Kernel extends Step<TestDescription, Program, TestContext> {
166 const Kernel(); 166 const Kernel();
167 167
168 String get name => "kernel"; 168 String get name => "kernel";
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } 225 }
226 } 226 }
227 227
228 class MatchExpectation extends Step<Program, Program, dynamic> { 228 class MatchExpectation extends Step<Program, Program, dynamic> {
229 final String suffix; 229 final String suffix;
230 230
231 // TODO(ahe): This is true by default which doesn't match well with the class 231 // TODO(ahe): This is true by default which doesn't match well with the class
232 // name. 232 // name.
233 final bool updateExpectations; 233 final bool updateExpectations;
234 234
235 const MatchExpectation(this.suffix, {this.updateExpectations: true}); 235 const MatchExpectation(this.suffix, {this.updateExpectations: false});
236 236
237 String get name => "match expectations"; 237 String get name => "match expectations";
238 238
239 Future<Result<Program>> run(Program program, _) async { 239 Future<Result<Program>> run(Program program, _) async {
240 Library library = program.libraries.firstWhere( 240 Library library = program.libraries.firstWhere(
241 (Library library) => library.importUri.scheme != "dart"); 241 (Library library) => library.importUri.scheme != "dart");
242 Uri uri = library.importUri; 242 Uri uri = library.importUri;
243 StringBuffer buffer = new StringBuffer(); 243 StringBuffer buffer = new StringBuffer();
244 new Printer(buffer).writeLibraryFile(library); 244 new Printer(buffer).writeLibraryFile(library);
245 245
246 bool updateExpectations = this.updateExpectations;
247 if (uri.path.contains("/test/fasta/rasta/")) {
248 // TODO(ahe): Remove this. Short term, we don't want to automatically
249 // update rasta expectations, as we have too many failures.
250 updateExpectations = false;
251 }
252 File expectedFile = new File("${uri.toFilePath()}$suffix"); 246 File expectedFile = new File("${uri.toFilePath()}$suffix");
253 if (await expectedFile.exists()) { 247 if (await expectedFile.exists()) {
254 String expected = await expectedFile.readAsString(); 248 String expected = await expectedFile.readAsString();
255 if (expected.trim() != "$buffer".trim()) { 249 if (expected.trim() != "$buffer".trim()) {
256 if (!updateExpectations) { 250 if (!updateExpectations) {
257 String diff = await runDiff(expectedFile.uri, "$buffer"); 251 String diff = await runDiff(expectedFile.uri, "$buffer");
258 return fail(null, "$uri doesn't match ${expectedFile.uri}\n$diff"); 252 return fail(null, "$uri doesn't match ${expectedFile.uri}\n$diff");
259 } 253 }
260 } else { 254 } else {
261 return pass(program); 255 return pass(program);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 375
382 Future openWrite(Uri uri, f(IOSink sink)) async { 376 Future openWrite(Uri uri, f(IOSink sink)) async {
383 IOSink sink = new File.fromUri(uri).openWrite(); 377 IOSink sink = new File.fromUri(uri).openWrite();
384 try { 378 try {
385 await f(sink); 379 await f(sink);
386 } finally { 380 } finally {
387 await sink.close(); 381 await sink.close();
388 } 382 }
389 print("Wrote $uri"); 383 print("Wrote $uri");
390 } 384 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698