| 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 library fasta.testing.suite; | 5 library fasta.testing.suite; |
| 6 | 6 |
| 7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
| 8 | 8 |
| 9 import 'dart:convert' show JSON; | 9 import 'dart:convert' show JSON; |
| 10 | 10 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 String get name { | 173 String get name { |
| 174 return fullCompile ? "${astKind} compile" : "outline"; | 174 return fullCompile ? "${astKind} compile" : "outline"; |
| 175 } | 175 } |
| 176 | 176 |
| 177 bool get isCompiler => fullCompile; | 177 bool get isCompiler => fullCompile; |
| 178 | 178 |
| 179 Future<Result<Program>> run( | 179 Future<Result<Program>> run( |
| 180 TestDescription description, FastaContext context) async { | 180 TestDescription description, FastaContext context) async { |
| 181 Program platform = await context.createPlatform(); | 181 Program platform = await context.createPlatform(); |
| 182 Ticker ticker = new Ticker(); | 182 Ticker ticker = new Ticker(); |
| 183 DillTarget dillTarget = new DillTarget(ticker, context.uriTranslator); | 183 DillTarget dillTarget = |
| 184 new DillTarget(ticker, context.uriTranslator, strongMode); |
| 184 dillTarget.loader | 185 dillTarget.loader |
| 185 ..input = Uri.parse("org.dartlang:platform") // Make up a name. | 186 ..input = Uri.parse("org.dartlang:platform") // Make up a name. |
| 186 ..setProgram(platform); | 187 ..setProgram(platform); |
| 187 KernelTarget sourceTarget = astKind == AstKind.Analyzer | 188 KernelTarget sourceTarget = astKind == AstKind.Analyzer |
| 188 ? new AnalyzerTarget(dillTarget, context.uriTranslator, strongMode) | 189 ? new AnalyzerTarget(dillTarget, context.uriTranslator, strongMode) |
| 189 : new KernelTarget(dillTarget, context.uriTranslator, strongMode); | 190 : new KernelTarget(dillTarget, context.uriTranslator, strongMode); |
| 190 | 191 |
| 191 Program p; | 192 Program p; |
| 192 try { | 193 try { |
| 193 sourceTarget.read(description.uri); | 194 sourceTarget.read(description.uri); |
| 194 await dillTarget.writeOutline(null); | 195 await dillTarget.writeOutline(null); |
| 195 var instrumentation = new ValidatingInstrumentation(); | 196 ValidatingInstrumentation instrumentation; |
| 196 await instrumentation.loadExpectations(description.uri); | 197 if (strongMode) { |
| 197 sourceTarget.loader.instrumentation = instrumentation; | 198 instrumentation = new ValidatingInstrumentation(); |
| 199 await instrumentation.loadExpectations(description.uri); |
| 200 sourceTarget.loader.instrumentation = instrumentation; |
| 201 } |
| 198 p = await sourceTarget.writeOutline(null); | 202 p = await sourceTarget.writeOutline(null); |
| 199 if (fullCompile) { | 203 if (fullCompile) { |
| 200 p = await sourceTarget.writeProgram(null); | 204 p = await sourceTarget.writeProgram(null); |
| 201 instrumentation.finish(); | 205 instrumentation?.finish(); |
| 202 if (instrumentation.hasProblems) { | 206 if (instrumentation != null && instrumentation.hasProblems) { |
| 203 if (updateExpectations) { | 207 if (updateExpectations) { |
| 204 await instrumentation.fixSource(description.uri); | 208 await instrumentation.fixSource(description.uri); |
| 205 } else { | 209 } else { |
| 206 return fail(null, instrumentation.problemsAsString); | 210 return fail(null, instrumentation.problemsAsString); |
| 207 } | 211 } |
| 208 } | 212 } |
| 209 } | 213 } |
| 210 } on InputError catch (e, s) { | 214 } on InputError catch (e, s) { |
| 211 return fail(null, e.error, s); | 215 return fail(null, e.error, s); |
| 212 } | 216 } |
| 213 return pass(p); | 217 return pass(p); |
| 214 } | 218 } |
| 215 } | 219 } |
| OLD | NEW |