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

Side by Side Diff: pkg/kernel/test/reify/suite.dart

Issue 2697873007: Merge the work on Generic Types Reification from 'dart-lang/reify' repo (Closed)
Patch Set: Get back parameter erroneously removed by previous commit Created 3 years, 10 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
« no previous file with comments | « pkg/kernel/test/reify/reify.status ('k') | pkg/kernel/test/reify/testing.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 test.kernel.closures.suite; 5 library test.kernel.reify.suite;
6 6
7 import 'dart:async' show Future; 7 import 'dart:async' show Future;
8 8
9 import 'dart:io' show Directory, File, Platform; 9 import 'dart:io' show Directory, File, Platform;
10 10
11 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; 11 import 'package:analyzer/src/generated/sdk.dart' show DartSdk;
12 12
13 import 'package:kernel/analyzer/loader.dart' 13 import 'package:kernel/analyzer/loader.dart'
14 show DartLoader, DartOptions, createDartSdk; 14 show DartLoader, DartOptions, createDartSdk;
15 15
(...skipping 12 matching lines...) Expand all
28 StdioProcess, 28 StdioProcess,
29 Step, 29 Step,
30 TestDescription, 30 TestDescription,
31 runMe; 31 runMe;
32 32
33 import 'package:kernel/ast.dart' show Program; 33 import 'package:kernel/ast.dart' show Program;
34 34
35 import 'package:kernel/transformations/closure_conversion.dart' 35 import 'package:kernel/transformations/closure_conversion.dart'
36 as closure_conversion; 36 as closure_conversion;
37 37
38 import 'package:kernel/transformations/generic_types_reification.dart'
39 as generic_types_reification;
40
38 import 'package:package_config/discovery.dart' show loadPackagesFile; 41 import 'package:package_config/discovery.dart' show loadPackagesFile;
39 42
40 class TestContext extends ChainContext { 43 class TestContext extends ChainContext {
41 final Uri vm; 44 final Uri vm;
42 45
43 final Uri packages; 46 final Uri packages;
44 47
45 final DartOptions options; 48 final DartOptions options;
46 49
47 final DartSdk dartSdk; 50 final DartSdk dartSdk;
48 51
49 final List<Step> steps; 52 final List<Step> steps;
50 53
51 TestContext(String sdk, this.vm, Uri packages, bool strongMode, this.dartSdk, 54 TestContext(String sdk, this.vm, Uri packages, bool strongMode, this.dartSdk,
52 bool updateExpectations) 55 bool updateExpectations)
53 : packages = packages, 56 : packages = packages,
54 options = new DartOptions( 57 options = new DartOptions(
55 strongMode: strongMode, 58 strongMode: strongMode,
56 sdk: sdk, 59 sdk: sdk,
57 packagePath: packages.toFilePath()), 60 packagePath: packages.toFilePath()),
58 steps = <Step>[ 61 steps = <Step>[
59 const Kernel(), 62 const Kernel(),
60 const Print(), 63 const Print(),
61 const SanityCheck(), 64 const SanityCheck(),
62 const ClosureConversion(), 65 const ClosureConversion(),
66 const GenericTypesReification(),
63 const Print(), 67 const Print(),
64 const SanityCheck(), 68 const SanityCheck(),
65 new MatchExpectation(".expect", 69 new MatchExpectation(".expect",
66 updateExpectations: updateExpectations), 70 updateExpectations: updateExpectations),
67 const WriteDill(), 71 const WriteDill(),
68 const ReadDill(), 72 const ReadDill(),
69 const Run(), 73 const Run(),
70 ]; 74 ];
71 75
72 Future<DartLoader> createLoader() async { 76 Future<DartLoader> createLoader() async {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 if (await fileExists(sdkUri, asyncSources)) { 123 if (await fileExists(sdkUri, asyncSources)) {
120 throw "Found '$asyncSources' in '$sdk', so it isn't a patched SDK. " 124 throw "Found '$asyncSources' in '$sdk', so it isn't a patched SDK. "
121 "$suggestion"; 125 "$suggestion";
122 } 126 }
123 127
124 // TODO(karlklose): select the VM based on the mode. 128 // TODO(karlklose): select the VM based on the mode.
125 Uri vm = Uri.base.resolve("out/ReleaseX64/dart"); 129 Uri vm = Uri.base.resolve("out/ReleaseX64/dart");
126 130
127 Uri packages = Uri.base.resolve(".packages"); 131 Uri packages = Uri.base.resolve(".packages");
128 bool strongMode = false; 132 bool strongMode = false;
129 bool updateExpectations = environment["updateExpectations"] != "false"; 133 bool updateExpectations = environment["updateExpectations"] == "true";
130 return new TestContext(sdk, vm, packages, strongMode, 134 return new TestContext(sdk, vm, packages, strongMode,
131 createDartSdk(sdk, strongMode: strongMode), updateExpectations); 135 createDartSdk(sdk, strongMode: strongMode), updateExpectations);
132 } 136 }
133 137
134 class Kernel extends Step<TestDescription, Program, TestContext> { 138 class Kernel extends Step<TestDescription, Program, TestContext> {
135 const Kernel(); 139 const Kernel();
136 140
137 String get name => "kernel"; 141 String get name => "kernel";
138 142
139 Future<Result<Program>> run( 143 Future<Result<Program>> run(
140 TestDescription description, TestContext testContext) async { 144 TestDescription description, TestContext testContext) async {
141 try { 145 try {
142 DartLoader loader = await testContext.createLoader(); 146 DartLoader loader = await testContext.createLoader();
147
143 Target target = getTarget( 148 Target target = getTarget(
144 "vm", new TargetFlags(strongMode: testContext.options.strongMode)); 149 "vm", new TargetFlags(strongMode: testContext.options.strongMode));
150 // reifyTarget is used to add the GTR-specific runtime libraries
151 // when the program is being loaded
152 Target reifyTarget = getTarget(
153 "vmreify",
154 new TargetFlags(
155 strongMode: testContext.options.strongMode,
156 kernelRuntime: Platform.script.resolve('../../runtime/')));
157
145 String path = description.file.path; 158 String path = description.file.path;
146 Uri uri = Uri.base.resolve(path); 159 Uri uri = Uri.base.resolve(path);
147 Program program = loader.loadProgram(uri, target: target); 160 Program program = loader.loadProgram(uri, target: reifyTarget);
148 for (var error in loader.errors) { 161 for (var error in loader.errors) {
149 return fail(program, "$error"); 162 return fail(program, "$error");
150 } 163 }
151 target 164 target
152 ..performModularTransformations(program) 165 ..performModularTransformations(program)
153 ..performGlobalTransformations(program); 166 ..performGlobalTransformations(program);
154 return pass(program); 167 return pass(program);
155 } catch (e, s) { 168 } catch (e, s) {
156 return crash(e, s); 169 return crash(e, s);
157 } 170 }
158 } 171 }
159 } 172 }
160 173
161 class ClosureConversion extends Step<Program, Program, TestContext> { 174 class ClosureConversion extends Step<Program, Program, TestContext> {
162 const ClosureConversion(); 175 const ClosureConversion();
163 176
164 String get name => "closure conversion"; 177 String get name => "closure conversion";
165 178
166 Future<Result<Program>> run(Program program, TestContext testContext) async { 179 Future<Result<Program>> run(Program program, TestContext testContext) async {
167 try { 180 try {
168 program = closure_conversion.transformProgram(program); 181 program = closure_conversion.transformProgram(program);
169 return pass(program); 182 return pass(program);
170 } catch (e, s) { 183 } catch (e, s) {
171 return crash(e, s); 184 return crash(e, s);
172 } 185 }
173 } 186 }
174 } 187 }
175 188
189 class GenericTypesReification extends Step<Program, Program, TestContext> {
190 const GenericTypesReification();
191
192 String get name => "generic types reification";
193
194 Future<Result<Program>> run(Program program, TestContext testContext) async {
195 try {
196 program = generic_types_reification.transformProgram(program);
197 return pass(program);
198 } catch (e, s) {
199 return crash(e, s);
200 }
201 }
202 }
203
176 class Run extends Step<Uri, int, TestContext> { 204 class Run extends Step<Uri, int, TestContext> {
177 const Run(); 205 const Run();
178 206
179 String get name => "run"; 207 String get name => "run";
180 208
181 Future<Result<int>> run(Uri uri, TestContext context) async { 209 Future<Result<int>> run(Uri uri, TestContext context) async {
182 File generated = new File.fromUri(uri); 210 File generated = new File.fromUri(uri);
183 StdioProcess process; 211 StdioProcess process;
184 try { 212 try {
185 process = await StdioProcess 213 process =
186 .run(context.vm.toFilePath(), [generated.path, "Hello, World!"]); 214 await StdioProcess.run(context.vm.toFilePath(), [generated.path]);
187 print(process.output); 215 print(process.output);
188 } finally { 216 } finally {
189 generated.parent.delete(recursive: true); 217 generated.parent.delete(recursive: true);
190 } 218 }
191 return process.toResult(); 219 return process.toResult();
192 } 220 }
193 } 221 }
194 222
195 main(List<String> arguments) => runMe(arguments, createContext, "testing.json"); 223 main(List<String> arguments) => runMe(arguments, createContext, "testing.json");
OLDNEW
« no previous file with comments | « pkg/kernel/test/reify/reify.status ('k') | pkg/kernel/test/reify/testing.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698