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

Side by Side Diff: pkg/front_end/test/fasta/testing/suite.dart

Issue 2919003003: Reapply "Use backend targets to run Kernel transformations in Fasta" (Closed)
Patch Set: Follow dartanalyzer suggestions Created 3 years, 6 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 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
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 import 'package:analyzer/src/fasta/analyzer_target.dart' show AnalyzerTarget; 44 import 'package:analyzer/src/fasta/analyzer_target.dart' show AnalyzerTarget;
45 45
46 import 'package:front_end/src/fasta/kernel/kernel_target.dart' 46 import 'package:front_end/src/fasta/kernel/kernel_target.dart'
47 show KernelTarget; 47 show KernelTarget;
48 48
49 import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget; 49 import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget;
50 50
51 import 'package:kernel/kernel.dart' show loadProgramFromBytes; 51 import 'package:kernel/kernel.dart' show loadProgramFromBytes;
52 52
53 import 'package:kernel/target/targets.dart' show TargetFlags;
54
53 export 'package:testing/testing.dart' show Chain, runMe; 55 export 'package:testing/testing.dart' show Chain, runMe;
54 56
55 const String STRONG_MODE = " strong mode "; 57 const String STRONG_MODE = " strong mode ";
56 58
57 const String ENABLE_FULL_COMPILE = " full compile "; 59 const String ENABLE_FULL_COMPILE = " full compile ";
58 60
59 const String AST_KIND_INDEX = " AST kind index "; 61 const String AST_KIND_INDEX = " AST kind index ";
60 62
61 const String EXPECTATIONS = ''' 63 const String EXPECTATIONS = '''
62 [ 64 [
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 211
210 bool get isCompiler => fullCompile; 212 bool get isCompiler => fullCompile;
211 213
212 Future<Result<Program>> run( 214 Future<Result<Program>> run(
213 TestDescription description, FastaContext context) async { 215 TestDescription description, FastaContext context) async {
214 // Disable colors to ensure that expectation files are the same across 216 // Disable colors to ensure that expectation files are the same across
215 // platforms and independent of stdin/stderr. 217 // platforms and independent of stdin/stderr.
216 CompilerContext.current.disableColors(); 218 CompilerContext.current.disableColors();
217 Program platformOutline = await context.loadPlatformOutline(); 219 Program platformOutline = await context.loadPlatformOutline();
218 Ticker ticker = new Ticker(); 220 Ticker ticker = new Ticker();
219 DillTarget dillTarget = new DillTarget(ticker, context.uriTranslator, "vm"); 221 DillTarget dillTarget = new DillTarget(
222 ticker, context.uriTranslator, "vm_fasta",
223 flags: new TargetFlags(strongMode: strongMode));
220 platformOutline.unbindCanonicalNames(); 224 platformOutline.unbindCanonicalNames();
221 dillTarget.loader.appendLibraries(platformOutline); 225 dillTarget.loader.appendLibraries(platformOutline);
222 // We create a new URI translator to avoid reading plaform libraries from 226 // We create a new URI translator to avoid reading plaform libraries from
223 // file system. 227 // file system.
224 TranslateUri uriTranslator = new TranslateUri( 228 TranslateUri uriTranslator = new TranslateUri(
225 context.uriTranslator.packages, 229 context.uriTranslator.packages,
226 const <String, Uri>{}, 230 const <String, Uri>{},
227 const <String, List<Uri>>{}); 231 const <String, List<Uri>>{});
228 KernelTarget sourceTarget = astKind == AstKind.Analyzer 232 KernelTarget sourceTarget = astKind == AstKind.Analyzer
229 ? new AnalyzerTarget(dillTarget, uriTranslator, strongMode) 233 ? new AnalyzerTarget(dillTarget, uriTranslator, strongMode)
230 : new KernelTarget( 234 : new KernelTarget(
231 PhysicalFileSystem.instance, dillTarget, uriTranslator, strongMode); 235 PhysicalFileSystem.instance, dillTarget, uriTranslator);
232 236
233 Program p; 237 Program p;
234 try { 238 try {
235 sourceTarget.read(description.uri); 239 sourceTarget.read(description.uri);
236 await dillTarget.buildOutlines(); 240 await dillTarget.buildOutlines();
237 ValidatingInstrumentation instrumentation; 241 ValidatingInstrumentation instrumentation;
238 if (strongMode) { 242 if (strongMode) {
239 instrumentation = new ValidatingInstrumentation(); 243 instrumentation = new ValidatingInstrumentation();
240 await instrumentation.loadExpectations(description.uri); 244 await instrumentation.loadExpectations(description.uri);
241 sourceTarget.loader.instrumentation = instrumentation; 245 sourceTarget.loader.instrumentation = instrumentation;
242 } 246 }
243 p = await sourceTarget.buildOutlines(); 247 p = await sourceTarget.buildOutlines();
244 if (fullCompile) { 248 if (fullCompile) {
245 p = await sourceTarget.buildProgram(trimDependencies: true); 249 p = await sourceTarget.buildProgram(trimDependencies: true);
246 instrumentation?.finish(); 250 instrumentation?.finish();
247 if (instrumentation != null && instrumentation.hasProblems) { 251 if (instrumentation != null && instrumentation.hasProblems) {
248 if (updateComments) { 252 if (updateComments) {
249 await instrumentation.fixSource(description.uri, false); 253 await instrumentation.fixSource(description.uri, false);
250 } else { 254 } else {
251 return fail(null, instrumentation.problemsAsString); 255 return fail(null, instrumentation.problemsAsString);
252 } 256 }
253 } 257 }
254 } 258 }
255 } on InputError catch (e, s) { 259 } on InputError catch (e, s) {
256 return fail(null, e.error, s); 260 return fail(null, e.error, s);
257 } 261 }
258 return pass(p); 262 return pass(p);
259 } 263 }
260 } 264 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698