| OLD | NEW |
| 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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 240 |
| 241 String get name => "match expectations"; | 241 String get name => "match expectations"; |
| 242 | 242 |
| 243 Future<Result<Program>> run(Program program, _) async { | 243 Future<Result<Program>> run(Program program, _) async { |
| 244 Library library = program.libraries.firstWhere( | 244 Library library = program.libraries.firstWhere( |
| 245 (Library library) => library.importUri.scheme != "dart"); | 245 (Library library) => library.importUri.scheme != "dart"); |
| 246 Uri uri = library.importUri; | 246 Uri uri = library.importUri; |
| 247 StringBuffer buffer = new StringBuffer(); | 247 StringBuffer buffer = new StringBuffer(); |
| 248 new Printer(buffer).writeLibraryFile(library); | 248 new Printer(buffer).writeLibraryFile(library); |
| 249 | 249 |
| 250 bool updateExpectations = this.updateExpectations; |
| 251 if (uri.path.contains("/test/rasta/")) { |
| 252 // TODO(ahe): Remove this. Short term, we don't want to automatically |
| 253 // update rasta expectations, as we have too many failures. |
| 254 updateExpectations = false; |
| 255 } |
| 250 File expectedFile = new File("${uri.toFilePath()}$suffix"); | 256 File expectedFile = new File("${uri.toFilePath()}$suffix"); |
| 251 if (await expectedFile.exists()) { | 257 if (await expectedFile.exists()) { |
| 252 String expected = await expectedFile.readAsString(); | 258 String expected = await expectedFile.readAsString(); |
| 253 if (expected.trim() != "$buffer".trim()) { | 259 if (expected.trim() != "$buffer".trim()) { |
| 254 if (!updateExpectations) { | 260 if (!updateExpectations) { |
| 255 String diff = await runDiff(expectedFile.uri, "$buffer"); | 261 String diff = await runDiff(expectedFile.uri, "$buffer"); |
| 256 return fail(null, "$uri doesn't match ${expectedFile.uri}\n$diff"); | 262 return fail(null, "$uri doesn't match ${expectedFile.uri}\n$diff"); |
| 257 } | 263 } |
| 258 } else { | 264 } else { |
| 259 return pass(program); | 265 return pass(program); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 | 385 |
| 380 Future openWrite(Uri uri, f(IOSink sink)) async { | 386 Future openWrite(Uri uri, f(IOSink sink)) async { |
| 381 IOSink sink = new File.fromUri(uri).openWrite(); | 387 IOSink sink = new File.fromUri(uri).openWrite(); |
| 382 try { | 388 try { |
| 383 await f(sink); | 389 await f(sink); |
| 384 } finally { | 390 } finally { |
| 385 await sink.close(); | 391 await sink.close(); |
| 386 } | 392 } |
| 387 print("Wrote $uri"); | 393 print("Wrote $uri"); |
| 388 } | 394 } |
| OLD | NEW |