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

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

Issue 2894273002: Revert "First step for modular output in fasta." (Closed)
Patch Set: 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 loadProgramFromBytes; 47 import 'package:kernel/kernel.dart' show loadProgramFromBinary;
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;
89 88
90 final ExpectationSet expectationSet = 89 final ExpectationSet expectationSet =
91 new ExpectationSet.fromJsonList(JSON.decode(EXPECTATIONS)); 90 new ExpectationSet.fromJsonList(JSON.decode(EXPECTATIONS));
92 91
92 Future<Program> outline;
93
93 FastaContext( 94 FastaContext(
94 this.vm, 95 this.vm,
95 bool strongMode, 96 bool strongMode,
96 bool updateExpectations, 97 bool updateExpectations,
97 bool updateComments, 98 bool updateComments,
98 bool skipVm, 99 bool skipVm,
99 this.uriTranslator, 100 this.uriTranslator,
100 bool fullCompile, 101 bool fullCompile,
101 AstKind astKind) 102 AstKind astKind)
102 : steps = <Step>[ 103 : steps = <Step>[
(...skipping 14 matching lines...) Expand all
117 } 118 }
118 119
119 Future ensurePlatformUris() async { 120 Future ensurePlatformUris() async {
120 if (sdk == null) { 121 if (sdk == null) {
121 sdk = await computePatchedSdk(); 122 sdk = await computePatchedSdk();
122 platformUri = sdk.resolve('platform.dill'); 123 platformUri = sdk.resolve('platform.dill');
123 outlineUri = sdk.resolve('outline.dill'); 124 outlineUri = sdk.resolve('outline.dill');
124 } 125 }
125 } 126 }
126 127
127 Future<Program> loadPlatformOutline() async { 128 Future<Program> loadPlatformOutline() {
128 if (outlineBytes == null) { 129 return outline ??= new Future<Program>(() async {
129 await ensurePlatformUris(); 130 await ensurePlatformUris();
130 outlineBytes = new File.fromUri(outlineUri).readAsBytesSync(); 131 return loadProgramFromBinary(outlineUri.toFilePath());
131 } 132 });
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);
137 } 133 }
138 134
139 static Future<FastaContext> create( 135 static Future<FastaContext> create(
140 Chain suite, Map<String, String> environment) async { 136 Chain suite, Map<String, String> environment) async {
141 Uri sdk = await computePatchedSdk(); 137 Uri sdk = await computePatchedSdk();
142 Uri vm = computeDartVm(sdk); 138 Uri vm = computeDartVm(sdk);
143 Uri packages = Uri.base.resolve(".packages"); 139 Uri packages = Uri.base.resolve(".packages");
144 TranslateUri uriTranslator = 140 TranslateUri uriTranslator =
145 await TranslateUri.parse(PhysicalFileSystem.instance, packages); 141 await TranslateUri.parse(PhysicalFileSystem.instance, packages);
146 bool strongMode = environment.containsKey(STRONG_MODE); 142 bool strongMode = environment.containsKey(STRONG_MODE);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 sourceTarget.read(description.uri); 218 sourceTarget.read(description.uri);
223 await dillTarget.buildOutlines(); 219 await dillTarget.buildOutlines();
224 ValidatingInstrumentation instrumentation; 220 ValidatingInstrumentation instrumentation;
225 if (strongMode) { 221 if (strongMode) {
226 instrumentation = new ValidatingInstrumentation(); 222 instrumentation = new ValidatingInstrumentation();
227 await instrumentation.loadExpectations(description.uri); 223 await instrumentation.loadExpectations(description.uri);
228 sourceTarget.loader.instrumentation = instrumentation; 224 sourceTarget.loader.instrumentation = instrumentation;
229 } 225 }
230 p = await sourceTarget.buildOutlines(); 226 p = await sourceTarget.buildOutlines();
231 if (fullCompile) { 227 if (fullCompile) {
232 p = await sourceTarget.buildProgram(trimDependencies: true); 228 p = await sourceTarget.buildProgram();
233 instrumentation?.finish(); 229 instrumentation?.finish();
234 if (instrumentation != null && instrumentation.hasProblems) { 230 if (instrumentation != null && instrumentation.hasProblems) {
235 if (updateComments) { 231 if (updateComments) {
236 await instrumentation.fixSource(description.uri); 232 await instrumentation.fixSource(description.uri);
237 } else { 233 } else {
238 return fail(null, instrumentation.problemsAsString); 234 return fail(null, instrumentation.problemsAsString);
239 } 235 }
240 } 236 }
241 } 237 }
242 } on InputError catch (e, s) { 238 } on InputError catch (e, s) {
243 return fail(null, e.error, s); 239 return fail(null, e.error, s);
244 } 240 }
245 return pass(p); 241 return pass(p);
246 } 242 }
247 } 243 }
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