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:io' show File; | 9 import 'dart:io' show File; |
10 | 10 |
11 import 'dart:convert' show JSON; | 11 import 'dart:convert' show JSON; |
12 | 12 |
| 13 import 'package:front_end/physical_file_system.dart'; |
13 import 'package:front_end/src/fasta/testing/validating_instrumentation.dart' | 14 import 'package:front_end/src/fasta/testing/validating_instrumentation.dart' |
14 show ValidatingInstrumentation; | 15 show ValidatingInstrumentation; |
15 | 16 |
16 import 'package:front_end/src/fasta/testing/patched_sdk_location.dart'; | 17 import 'package:front_end/src/fasta/testing/patched_sdk_location.dart'; |
17 | 18 |
18 import 'package:kernel/ast.dart' show Program; | 19 import 'package:kernel/ast.dart' show Program; |
19 | 20 |
20 import 'package:testing/testing.dart' | 21 import 'package:testing/testing.dart' |
21 show | 22 show |
22 Chain, | 23 Chain, |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 Uri sdk = await computePatchedSdk(); | 112 Uri sdk = await computePatchedSdk(); |
112 return loadProgramFromBinary(sdk.resolve('platform.dill').toFilePath()); | 113 return loadProgramFromBinary(sdk.resolve('platform.dill').toFilePath()); |
113 }); | 114 }); |
114 } | 115 } |
115 | 116 |
116 static Future<FastaContext> create( | 117 static Future<FastaContext> create( |
117 Chain suite, Map<String, String> environment) async { | 118 Chain suite, Map<String, String> environment) async { |
118 Uri sdk = await computePatchedSdk(); | 119 Uri sdk = await computePatchedSdk(); |
119 Uri vm = computeDartVm(sdk); | 120 Uri vm = computeDartVm(sdk); |
120 Uri packages = Uri.base.resolve(".packages"); | 121 Uri packages = Uri.base.resolve(".packages"); |
121 TranslateUri uriTranslator = await TranslateUri.parse(packages); | 122 TranslateUri uriTranslator = |
| 123 await TranslateUri.parse(PhysicalFileSystem.instance, packages); |
122 bool strongMode = environment.containsKey(STRONG_MODE); | 124 bool strongMode = environment.containsKey(STRONG_MODE); |
123 bool updateExpectations = environment["updateExpectations"] == "true"; | 125 bool updateExpectations = environment["updateExpectations"] == "true"; |
124 String astKindString = environment[AST_KIND_INDEX]; | 126 String astKindString = environment[AST_KIND_INDEX]; |
125 AstKind astKind = | 127 AstKind astKind = |
126 astKindString == null ? null : AstKind.values[int.parse(astKindString)]; | 128 astKindString == null ? null : AstKind.values[int.parse(astKindString)]; |
127 return new FastaContext(vm, strongMode, updateExpectations, uriTranslator, | 129 return new FastaContext(vm, strongMode, updateExpectations, uriTranslator, |
128 environment.containsKey(ENABLE_FULL_COMPILE), astKind); | 130 environment.containsKey(ENABLE_FULL_COMPILE), astKind); |
129 } | 131 } |
130 } | 132 } |
131 | 133 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 Future<Result<Program>> run( | 175 Future<Result<Program>> run( |
174 TestDescription description, FastaContext context) async { | 176 TestDescription description, FastaContext context) async { |
175 Program platform = await context.loadPlatform(); | 177 Program platform = await context.loadPlatform(); |
176 Ticker ticker = new Ticker(); | 178 Ticker ticker = new Ticker(); |
177 DillTarget dillTarget = new DillTarget(ticker, context.uriTranslator); | 179 DillTarget dillTarget = new DillTarget(ticker, context.uriTranslator); |
178 dillTarget.loader | 180 dillTarget.loader |
179 ..input = Uri.parse("org.dartlang:platform") // Make up a name. | 181 ..input = Uri.parse("org.dartlang:platform") // Make up a name. |
180 ..setProgram(platform); | 182 ..setProgram(platform); |
181 KernelTarget sourceTarget = astKind == AstKind.Analyzer | 183 KernelTarget sourceTarget = astKind == AstKind.Analyzer |
182 ? new AnalyzerTarget(dillTarget, context.uriTranslator, strongMode) | 184 ? new AnalyzerTarget(dillTarget, context.uriTranslator, strongMode) |
183 : new KernelTarget(dillTarget, context.uriTranslator, strongMode); | 185 : new KernelTarget(PhysicalFileSystem.instance, dillTarget, |
| 186 context.uriTranslator, strongMode); |
184 | 187 |
185 Program p; | 188 Program p; |
186 try { | 189 try { |
187 sourceTarget.read(description.uri); | 190 sourceTarget.read(description.uri); |
188 await dillTarget.writeOutline(null); | 191 await dillTarget.writeOutline(null); |
189 ValidatingInstrumentation instrumentation; | 192 ValidatingInstrumentation instrumentation; |
190 if (strongMode) { | 193 if (strongMode) { |
191 instrumentation = new ValidatingInstrumentation(); | 194 instrumentation = new ValidatingInstrumentation(); |
192 await instrumentation.loadExpectations(description.uri); | 195 await instrumentation.loadExpectations(description.uri); |
193 sourceTarget.loader.instrumentation = instrumentation; | 196 sourceTarget.loader.instrumentation = instrumentation; |
194 } | 197 } |
195 p = await sourceTarget.writeOutline(null); | 198 p = await sourceTarget.writeOutline(null); |
196 if (fullCompile) { | 199 if (fullCompile) { |
197 p = await sourceTarget.writeProgram(null); | 200 p = await sourceTarget.writeProgram(null); |
198 instrumentation?.finish(); | 201 instrumentation?.finish(); |
199 if (instrumentation != null && instrumentation.hasProblems) { | 202 if (instrumentation != null && instrumentation.hasProblems) { |
200 if (updateExpectations) { | 203 if (updateExpectations) { |
201 await instrumentation.fixSource(description.uri); | 204 await instrumentation.fixSource(description.uri); |
202 } else { | 205 } else { |
203 return fail(null, instrumentation.problemsAsString); | 206 return fail(null, instrumentation.problemsAsString); |
204 } | 207 } |
205 } | 208 } |
206 } | 209 } |
207 } on InputError catch (e, s) { | 210 } on InputError catch (e, s) { |
208 return fail(null, e.error, s); | 211 return fail(null, e.error, s); |
209 } | 212 } |
210 return pass(p); | 213 return pass(p); |
211 } | 214 } |
212 } | 215 } |
OLD | NEW |