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

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

Issue 2893493004: First step for modular output in fasta. (Closed)
Patch Set: cl comments Created 3 years, 7 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 26 matching lines...) Expand all
37 37
38 import 'package:front_end/src/fasta/translate_uri.dart' show TranslateUri; 38 import 'package:front_end/src/fasta/translate_uri.dart' show TranslateUri;
39 39
40 import 'package:analyzer/src/fasta/analyzer_target.dart' show AnalyzerTarget; 40 import 'package:analyzer/src/fasta/analyzer_target.dart' show AnalyzerTarget;
41 41
42 import 'package:front_end/src/fasta/kernel/kernel_target.dart' 42 import 'package:front_end/src/fasta/kernel/kernel_target.dart'
43 show KernelTarget; 43 show KernelTarget;
44 44
45 import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget; 45 import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget;
46 46
47 import 'package:kernel/kernel.dart' show loadProgramFromBinary; 47 import 'package:kernel/kernel.dart' show loadProgramFromBytes;
48 48
49 export 'package:testing/testing.dart' show Chain, runMe; 49 export 'package:testing/testing.dart' show Chain, runMe;
50 50
51 const String STRONG_MODE = " strong mode "; 51 const String STRONG_MODE = " strong mode ";
52 52
53 const String ENABLE_FULL_COMPILE = " full compile "; 53 const String ENABLE_FULL_COMPILE = " full compile ";
54 54
55 const String AST_KIND_INDEX = " AST kind index "; 55 const String AST_KIND_INDEX = " AST kind index ";
56 56
57 const String EXPECTATIONS = ''' 57 const String EXPECTATIONS = '''
(...skipping 20 matching lines...) Expand all
78 Kernel, 78 Kernel,
79 } 79 }
80 80
81 class FastaContext extends ChainContext { 81 class FastaContext extends ChainContext {
82 final TranslateUri uriTranslator; 82 final TranslateUri uriTranslator;
83 final List<Step> steps; 83 final List<Step> steps;
84 final Uri vm; 84 final Uri vm;
85 Uri sdk; 85 Uri sdk;
86 Uri platformUri; 86 Uri platformUri;
87 Uri outlineUri; 87 Uri outlineUri;
88 List<int> outlineBytes;
88 89
89 final ExpectationSet expectationSet = 90 final ExpectationSet expectationSet =
90 new ExpectationSet.fromJsonList(JSON.decode(EXPECTATIONS)); 91 new ExpectationSet.fromJsonList(JSON.decode(EXPECTATIONS));
91 92
92 Future<Program> outline;
93
94 FastaContext( 93 FastaContext(
95 this.vm, 94 this.vm,
96 bool strongMode, 95 bool strongMode,
97 bool updateExpectations, 96 bool updateExpectations,
98 bool updateComments, 97 bool updateComments,
99 bool skipVm, 98 bool skipVm,
100 this.uriTranslator, 99 this.uriTranslator,
101 bool fullCompile, 100 bool fullCompile,
102 AstKind astKind) 101 AstKind astKind)
103 : steps = <Step>[ 102 : steps = <Step>[
(...skipping 14 matching lines...) Expand all
118 } 117 }
119 118
120 Future ensurePlatformUris() async { 119 Future ensurePlatformUris() async {
121 if (sdk == null) { 120 if (sdk == null) {
122 sdk = await computePatchedSdk(); 121 sdk = await computePatchedSdk();
123 platformUri = sdk.resolve('platform.dill'); 122 platformUri = sdk.resolve('platform.dill');
124 outlineUri = sdk.resolve('outline.dill'); 123 outlineUri = sdk.resolve('outline.dill');
125 } 124 }
126 } 125 }
127 126
128 Future<Program> loadPlatformOutline() { 127 Future<Program> loadPlatformOutline() async {
129 return outline ??= new Future<Program>(() async { 128 if (outlineBytes == null) {
130 await ensurePlatformUris(); 129 await ensurePlatformUris();
131 return loadProgramFromBinary(outlineUri.toFilePath()); 130 outlineBytes = new File.fromUri(outlineUri).readAsBytesSync();
132 }); 131 }
132 // Note: we rebuild the platform outline on every test because the compiler
133 // currently mutates the in-memory representation of the program without
134 // cloning it.
135 // TODO(sigmund): investigate alternatives to this approach.
136 return loadProgramFromBytes(outlineBytes);
133 } 137 }
134 138
135 static Future<FastaContext> create( 139 static Future<FastaContext> create(
136 Chain suite, Map<String, String> environment) async { 140 Chain suite, Map<String, String> environment) async {
137 Uri sdk = await computePatchedSdk(); 141 Uri sdk = await computePatchedSdk();
138 Uri vm = computeDartVm(sdk); 142 Uri vm = computeDartVm(sdk);
139 Uri packages = Uri.base.resolve(".packages"); 143 Uri packages = Uri.base.resolve(".packages");
140 TranslateUri uriTranslator = 144 TranslateUri uriTranslator =
141 await TranslateUri.parse(PhysicalFileSystem.instance, packages); 145 await TranslateUri.parse(PhysicalFileSystem.instance, packages);
142 bool strongMode = environment.containsKey(STRONG_MODE); 146 bool strongMode = environment.containsKey(STRONG_MODE);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 sourceTarget.read(description.uri); 222 sourceTarget.read(description.uri);
219 await dillTarget.buildOutlines(); 223 await dillTarget.buildOutlines();
220 ValidatingInstrumentation instrumentation; 224 ValidatingInstrumentation instrumentation;
221 if (strongMode) { 225 if (strongMode) {
222 instrumentation = new ValidatingInstrumentation(); 226 instrumentation = new ValidatingInstrumentation();
223 await instrumentation.loadExpectations(description.uri); 227 await instrumentation.loadExpectations(description.uri);
224 sourceTarget.loader.instrumentation = instrumentation; 228 sourceTarget.loader.instrumentation = instrumentation;
225 } 229 }
226 p = await sourceTarget.buildOutlines(); 230 p = await sourceTarget.buildOutlines();
227 if (fullCompile) { 231 if (fullCompile) {
228 p = await sourceTarget.buildProgram(); 232 p = await sourceTarget.buildProgram(trimDependencies: true);
229 instrumentation?.finish(); 233 instrumentation?.finish();
230 if (instrumentation != null && instrumentation.hasProblems) { 234 if (instrumentation != null && instrumentation.hasProblems) {
231 if (updateComments) { 235 if (updateComments) {
232 await instrumentation.fixSource(description.uri); 236 await instrumentation.fixSource(description.uri);
233 } else { 237 } else {
234 return fail(null, instrumentation.problemsAsString); 238 return fail(null, instrumentation.problemsAsString);
235 } 239 }
236 } 240 }
237 } 241 }
238 } on InputError catch (e, s) { 242 } on InputError catch (e, s) {
239 return fail(null, e.error, s); 243 return fail(null, e.error, s);
240 } 244 }
241 return pass(p); 245 return pass(p);
242 } 246 }
243 } 247 }
OLDNEW
« no previous file with comments | « pkg/front_end/test/fasta/testing.json ('k') | pkg/front_end/test/src/base/processed_options_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698