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

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

Issue 2723113002: Consolidate analyzer dependencies. (Closed)
Patch Set: Remove new dependency on AsyncMarker. Created 3 years, 9 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:convert' show JSON; 9 import 'dart:convert' show JSON;
10 10
(...skipping 10 matching lines...) Expand all
21 21
22 import '../errors.dart' show InputError; 22 import '../errors.dart' show InputError;
23 23
24 import 'kernel_chain.dart' 24 import 'kernel_chain.dart'
25 show MatchExpectation, Print, Run, Verify, TestContext, WriteDill; 25 show MatchExpectation, Print, Run, Verify, TestContext, WriteDill;
26 26
27 import '../ticker.dart' show Ticker; 27 import '../ticker.dart' show Ticker;
28 28
29 import '../translate_uri.dart' show TranslateUri; 29 import '../translate_uri.dart' show TranslateUri;
30 30
31 import '../analyzer/analyzer_target.dart' show AnalyzerTarget;
32
31 import '../kernel/kernel_target.dart' show KernelTarget; 33 import '../kernel/kernel_target.dart' show KernelTarget;
32 34
33 import '../dill/dill_target.dart' show DillTarget; 35 import '../dill/dill_target.dart' show DillTarget;
34 36
35 import '../ast_kind.dart' show AstKind;
36
37 export 'kernel_chain.dart' show TestContext; 37 export 'kernel_chain.dart' show TestContext;
38 38
39 export 'package:testing/testing.dart' show Chain, runMe; 39 export 'package:testing/testing.dart' show Chain, runMe;
40 40
41 export '../ast_kind.dart' show AstKind;
42
43 const String ENABLE_FULL_COMPILE = " full compile "; 41 const String ENABLE_FULL_COMPILE = " full compile ";
44 42
45 const String AST_KIND_INDEX = " AST kind index "; 43 const String AST_KIND_INDEX = " AST kind index ";
46 44
47 const String EXPECTATIONS = ''' 45 const String EXPECTATIONS = '''
48 [ 46 [
49 { 47 {
50 "name": "VerificationError", 48 "name": "VerificationError",
51 "group": "Fail" 49 "group": "Fail"
52 } 50 }
53 ] 51 ]
54 '''; 52 ''';
55 53
56 String shortenAstKindName(AstKind astKind) { 54 String shortenAstKindName(AstKind astKind) {
57 switch (astKind) { 55 switch (astKind) {
58 case AstKind.Analyzer: 56 case AstKind.Analyzer:
59 return "dartk"; 57 return "dartk";
60 case AstKind.Kernel: 58 case AstKind.Kernel:
61 return "direct"; 59 return "direct";
62 } 60 }
63 throw "Unknown AST kind: $astKind"; 61 throw "Unknown AST kind: $astKind";
64 } 62 }
65 63
64 enum AstKind {
65 Analyzer,
66 Kernel,
67 }
68
66 class FastaContext extends TestContext { 69 class FastaContext extends TestContext {
67 final TranslateUri uriTranslator; 70 final TranslateUri uriTranslator;
68 71
69 final List<Step> steps; 72 final List<Step> steps;
70 73
71 final ExpectationSet expectationSet = 74 final ExpectationSet expectationSet =
72 new ExpectationSet.fromJsonList(JSON.decode(EXPECTATIONS)); 75 new ExpectationSet.fromJsonList(JSON.decode(EXPECTATIONS));
73 76
74 Future<Program> platform; 77 Future<Program> platform;
75 78
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 155 }
153 156
154 class Outline extends Step<TestDescription, Program, FastaContext> { 157 class Outline extends Step<TestDescription, Program, FastaContext> {
155 final bool fullCompile; 158 final bool fullCompile;
156 159
157 final AstKind astKind; 160 final AstKind astKind;
158 161
159 const Outline(this.fullCompile, this.astKind); 162 const Outline(this.fullCompile, this.astKind);
160 163
161 String get name { 164 String get name {
162 return fullCompile ? "${shortenAstKindName(astKind)} compile" : "outline"; 165 return fullCompile ? "${astKind} compile" : "outline";
163 } 166 }
164 167
165 bool get isCompiler => fullCompile; 168 bool get isCompiler => fullCompile;
166 169
167 Future<Result<Program>> run( 170 Future<Result<Program>> run(
168 TestDescription description, FastaContext context) async { 171 TestDescription description, FastaContext context) async {
169 Program platform = await context.createPlatform(); 172 Program platform = await context.createPlatform();
170 Ticker ticker = new Ticker(); 173 Ticker ticker = new Ticker();
171 DillTarget dillTarget = new DillTarget(ticker, context.uriTranslator); 174 DillTarget dillTarget = new DillTarget(ticker, context.uriTranslator);
172 dillTarget.loader 175 dillTarget.loader
173 ..input = Uri.parse("org.dartlang:platform") // Make up a name. 176 ..input = Uri.parse("org.dartlang:platform") // Make up a name.
174 ..setProgram(platform); 177 ..setProgram(platform);
175 KernelTarget sourceTarget = 178 KernelTarget sourceTarget = astKind == AstKind.Analyzer
176 new KernelTarget(dillTarget, context.uriTranslator); 179 ? new AnalyzerTarget(dillTarget, context.uriTranslator)
180 : new KernelTarget(dillTarget, context.uriTranslator);
181
177 Program p; 182 Program p;
178 try { 183 try {
179 sourceTarget.read(description.uri); 184 sourceTarget.read(description.uri);
180 await dillTarget.writeOutline(null); 185 await dillTarget.writeOutline(null);
181 p = await sourceTarget.writeOutline(null); 186 p = await sourceTarget.writeOutline(null);
182 if (fullCompile) { 187 if (fullCompile) {
183 p = await sourceTarget.writeProgram(null, astKind); 188 p = await sourceTarget.writeProgram(null);
184 } 189 }
185 } on InputError catch (e, s) { 190 } on InputError catch (e, s) {
186 return fail(null, e.error, s); 191 return fail(null, e.error, s);
187 } 192 }
188 return pass(p); 193 return pass(p);
189 } 194 }
190 } 195 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/target.dart ('k') | pkg/front_end/lib/src/fasta/util/link_implementation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698