Chromium Code Reviews| Index: pkg/kernel/test/closures/suite.dart |
| diff --git a/pkg/kernel/test/closures/suite.dart b/pkg/kernel/test/closures/suite.dart |
| index 6e246fac176b28f27ade41622041c5ab8fd0d1da..f434353f780aaabe1d2314b42e23ac21a091dc2e 100644 |
| --- a/pkg/kernel/test/closures/suite.dart |
| +++ b/pkg/kernel/test/closures/suite.dart |
| @@ -4,6 +4,8 @@ |
| library test.kernel.closures.suite; |
| +import 'dart:io' show File; |
| + |
| import 'dart:async' show Future; |
| import 'package:front_end/physical_file_system.dart' show PhysicalFileSystem; |
| @@ -11,16 +13,20 @@ import 'package:front_end/physical_file_system.dart' show PhysicalFileSystem; |
| import 'package:kernel/core_types.dart' show CoreTypes; |
| import 'package:testing/testing.dart' |
| - show Chain, ChainContext, Result, Step, TestDescription, runMe; |
| + show |
| + Chain, |
| + ChainContext, |
| + Result, |
| + Step, |
| + TestDescription, |
| + runMe, |
| + StdioProcess; |
| import 'package:front_end/src/fasta/testing/patched_sdk_location.dart' |
| show computePatchedSdk; |
| import 'package:kernel/ast.dart' show Program, Library; |
| -import 'package:kernel/transformations/closure_conversion.dart' |
| - as closure_conversion; |
| - |
| import 'package:front_end/src/fasta/testing/kernel_chain.dart' |
| show Print, MatchExpectation, WriteDill, ReadDill, Verify; |
| @@ -39,6 +45,9 @@ import 'package:front_end/src/fasta/testing/patched_sdk_location.dart'; |
| import 'package:kernel/kernel.dart' show loadProgramFromBinary; |
| +import 'package:kernel/transformations/closure_conversion.dart' |
| + as closure_conversion; |
| + |
| import 'package:kernel/target/targets.dart' show TargetFlags; |
| import 'package:kernel/target/vm_fasta.dart' show VmFastaTarget; |
| @@ -51,9 +60,10 @@ class ClosureConversionContext extends ChainContext { |
| final TranslateUri uriTranslator; |
| final List<Step> steps; |
| + final Uri vm; |
| ClosureConversionContext( |
| - this.strongMode, bool updateExpectations, this.uriTranslator) |
| + this.vm, this.strongMode, bool updateExpectations, this.uriTranslator) |
| : steps = <Step>[ |
| const FastaCompile(), |
| const Print(), |
| @@ -65,24 +75,30 @@ class ClosureConversionContext extends ChainContext { |
| updateExpectations: updateExpectations), |
| const WriteDill(), |
| const ReadDill(), |
| - // TODO(29143): add `Run` step when Vectors are added to VM. |
| + const Run(), |
| ]; |
| - Future<Program> loadPlatform() async { |
| - Uri sdk = await computePatchedSdk(); |
| - return loadProgramFromBinary(sdk.resolve('platform.dill').toFilePath()); |
| + // The platform in these tests are reloaded for each testscase, because the |
|
kustermann
2017/06/20 12:13:13
s/platform/platform.dill/
s/are reloaded/is reload
Dmitry Stefantsov
2017/06/22 14:12:52
Thanks for the suggestions! Actually, after disab
|
| + // closure conversion transformation is performed during the load, and it's |
| + // not an idempotent transformation yet. |
|
kustermann
2017/06/20 12:13:13
Maybe add a pointer (github issues / ...), so a re
Dmitry Stefantsov
2017/06/22 14:12:52
As stated above, after dealing with tear-offs was
|
| + Future<Program> loadPlatform() { |
| + return new Future<Program>(() async { |
| + Uri sdk = await computePatchedSdk(); |
| + return loadProgramFromBinary(sdk.resolve('platform.dill').toFilePath()); |
| + }); |
| } |
|
kustermann
2017/06/20 12:13:13
Why the extra trip to the event loop via `new Futu
Dmitry Stefantsov
2017/06/22 14:12:52
Good finding!
I think I was trying to lazily cach
|
| static Future<ClosureConversionContext> create( |
| Chain suite, Map<String, String> environment) async { |
| Uri sdk = await computePatchedSdk(); |
| + Uri vm = computeDartVm(sdk); |
| Uri packages = Uri.base.resolve(".packages"); |
| bool strongMode = environment.containsKey(STRONG_MODE); |
| bool updateExpectations = environment["updateExpectations"] == "true"; |
| TranslateUri uriTranslator = await TranslateUri |
| .parse(PhysicalFileSystem.instance, sdk, packages: packages); |
| return new ClosureConversionContext( |
| - strongMode, updateExpectations, uriTranslator); |
| + vm, strongMode, updateExpectations, uriTranslator); |
| } |
| } |
| @@ -143,4 +159,23 @@ class ClosureConversion |
| } |
| } |
| +class Run extends Step<Uri, int, ClosureConversionContext> { |
| + const Run(); |
| + |
| + String get name => "run"; |
| + |
| + Future<Result<int>> run(Uri uri, ClosureConversionContext context) async { |
| + File generated = new File.fromUri(uri); |
| + StdioProcess process; |
| + try { |
| + process = await StdioProcess |
| + .run(context.vm.toFilePath(), [generated.path, "Hello, World!"]); |
| + print(process.output); |
| + } finally { |
| + generated.parent.delete(recursive: true); |
| + } |
| + return process.toResult(); |
|
kustermann
2017/06/20 12:13:13
I think you could simplify this (slightly):
```da
Dmitry Stefantsov
2017/06/22 14:12:51
Agreed. I like this changed version better! I ch
|
| + } |
| +} |
| + |
| main(List<String> arguments) => runMe(arguments, createContext, "testing.json"); |