| 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 |
| 11 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; | 11 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; |
| 12 | 12 |
| 13 import 'package:front_end/src/fasta/testing/validating_instrumentation.dart' |
| 14 show ValidatingInstrumentation; |
| 15 |
| 13 import 'package:kernel/ast.dart' show Library, Program; | 16 import 'package:kernel/ast.dart' show Library, Program; |
| 14 | 17 |
| 15 import 'package:analyzer/src/kernel/loader.dart' show DartLoader; | 18 import 'package:analyzer/src/kernel/loader.dart' show DartLoader; |
| 16 | 19 |
| 17 import 'package:kernel/target/targets.dart' show Target, TargetFlags, getTarget; | 20 import 'package:kernel/target/targets.dart' show Target, TargetFlags, getTarget; |
| 18 | 21 |
| 19 import 'package:testing/testing.dart' | 22 import 'package:testing/testing.dart' |
| 20 show Chain, ExpectationSet, Result, Step, TestDescription; | 23 show Chain, ExpectationSet, Result, Step, TestDescription; |
| 21 | 24 |
| 22 import '../errors.dart' show InputError; | 25 import '../errors.dart' show InputError; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } | 157 } |
| 155 } | 158 } |
| 156 | 159 |
| 157 class Outline extends Step<TestDescription, Program, FastaContext> { | 160 class Outline extends Step<TestDescription, Program, FastaContext> { |
| 158 final bool fullCompile; | 161 final bool fullCompile; |
| 159 | 162 |
| 160 final AstKind astKind; | 163 final AstKind astKind; |
| 161 | 164 |
| 162 final bool strongMode; | 165 final bool strongMode; |
| 163 | 166 |
| 164 const Outline(this.fullCompile, this.astKind, this.strongMode); | 167 const Outline(this.fullCompile, this.astKind, this.strongMode, |
| 168 {this.updateExpectations: false}); |
| 169 |
| 170 final bool updateExpectations; |
| 165 | 171 |
| 166 String get name { | 172 String get name { |
| 167 return fullCompile ? "${astKind} compile" : "outline"; | 173 return fullCompile ? "${astKind} compile" : "outline"; |
| 168 } | 174 } |
| 169 | 175 |
| 170 bool get isCompiler => fullCompile; | 176 bool get isCompiler => fullCompile; |
| 171 | 177 |
| 172 Future<Result<Program>> run( | 178 Future<Result<Program>> run( |
| 173 TestDescription description, FastaContext context) async { | 179 TestDescription description, FastaContext context) async { |
| 174 Program platform = await context.createPlatform(); | 180 Program platform = await context.createPlatform(); |
| 175 Ticker ticker = new Ticker(); | 181 Ticker ticker = new Ticker(); |
| 176 DillTarget dillTarget = new DillTarget(ticker, context.uriTranslator); | 182 DillTarget dillTarget = new DillTarget(ticker, context.uriTranslator); |
| 177 dillTarget.loader | 183 dillTarget.loader |
| 178 ..input = Uri.parse("org.dartlang:platform") // Make up a name. | 184 ..input = Uri.parse("org.dartlang:platform") // Make up a name. |
| 179 ..setProgram(platform); | 185 ..setProgram(platform); |
| 180 KernelTarget sourceTarget = astKind == AstKind.Analyzer | 186 KernelTarget sourceTarget = astKind == AstKind.Analyzer |
| 181 ? new AnalyzerTarget(dillTarget, context.uriTranslator, strongMode) | 187 ? new AnalyzerTarget(dillTarget, context.uriTranslator, strongMode) |
| 182 : new KernelTarget(dillTarget, context.uriTranslator, strongMode); | 188 : new KernelTarget(dillTarget, context.uriTranslator, strongMode); |
| 183 | 189 |
| 184 Program p; | 190 Program p; |
| 185 try { | 191 try { |
| 186 sourceTarget.read(description.uri); | 192 sourceTarget.read(description.uri); |
| 187 await dillTarget.writeOutline(null); | 193 await dillTarget.writeOutline(null); |
| 194 var instrumentation = new ValidatingInstrumentation(); |
| 195 await instrumentation.loadExpectations(description.uri); |
| 196 sourceTarget.loader.instrumentation = instrumentation; |
| 188 p = await sourceTarget.writeOutline(null); | 197 p = await sourceTarget.writeOutline(null); |
| 189 if (fullCompile) { | 198 if (fullCompile) { |
| 190 p = await sourceTarget.writeProgram(null); | 199 p = await sourceTarget.writeProgram(null); |
| 200 instrumentation.finish(); |
| 201 if (instrumentation.hasProblems) { |
| 202 if (updateExpectations) { |
| 203 await instrumentation.fixSource(description.uri); |
| 204 } else { |
| 205 return fail(null, instrumentation.problemsAsString); |
| 206 } |
| 207 } |
| 191 } | 208 } |
| 192 } on InputError catch (e, s) { | 209 } on InputError catch (e, s) { |
| 193 return fail(null, e.error, s); | 210 return fail(null, e.error, s); |
| 194 } | 211 } |
| 195 return pass(p); | 212 return pass(p); |
| 196 } | 213 } |
| 197 } | 214 } |
| OLD | NEW |