Index: pkg/kernel/test/closures/suite.dart |
diff --git a/pkg/kernel/test/closures/suite.dart b/pkg/kernel/test/closures/suite.dart |
index e3a96ebf7529ec391786a596fe169d6ca0882b5f..a4f6404f98830e2f747b379e46a5f20bf0ac4b4a 100644 |
--- a/pkg/kernel/test/closures/suite.dart |
+++ b/pkg/kernel/test/closures/suite.dart |
@@ -4,19 +4,25 @@ |
library test.kernel.closures.suite; |
+import 'dart:io' show File; |
+ |
import 'dart:async' show Future; |
import 'package:front_end/physical_file_system.dart'; |
import 'package:testing/testing.dart' |
- show Chain, ChainContext, Result, Step, TestDescription, runMe; |
+ show |
+ Chain, |
+ ChainContext, |
+ Result, |
+ Step, |
+ TestDescription, |
+ runMe, |
+ StdioProcess; |
import 'package:kernel/ast.dart' show Program; |
-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; |
+ show TestContext, Print, MatchExpectation, WriteDill, ReadDill, Verify; |
import 'package:front_end/src/fasta/ticker.dart' show Ticker; |
@@ -36,42 +42,45 @@ import 'package:kernel/kernel.dart' show loadProgramFromBinary; |
const String STRONG_MODE = " strong mode "; |
class ClosureConversionContext extends ChainContext { |
- final bool strongMode; |
- |
final TranslateUri uriTranslator; |
- |
final List<Step> steps; |
+ final Uri vm; |
ClosureConversionContext( |
- this.strongMode, bool updateExpectations, this.uriTranslator) |
+ this.vm, bool strongMode, bool updateExpectations, this.uriTranslator) |
: steps = <Step>[ |
- const FastaCompile(), |
- const Print(), |
- const Verify(true), |
- const ClosureConversion(), |
+ new FastaCompile(strongMode), |
const Print(), |
const Verify(true), |
new MatchExpectation(".expect", |
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 |
+ // closure conversion transformation is performed during the load, and it's |
+ // not an idempotent transformation yet. |
+ Future<Program> loadPlatform() { |
+ return new Future<Program>(() async { |
+ Uri sdk = await computePatchedSdk(); |
+ return loadProgramFromBinary(sdk.resolve('platform.dill').toFilePath()); |
+ }); |
} |
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, packages); |
+ bool strongMode = environment.containsKey(STRONG_MODE); |
+ bool updateExpectations = environment["updateExpectations"] == "true"; |
+ |
return new ClosureConversionContext( |
- strongMode, updateExpectations, uriTranslator); |
+ vm, strongMode, updateExpectations, uriTranslator); |
} |
} |
@@ -84,7 +93,9 @@ Future<ClosureConversionContext> createContext( |
class FastaCompile |
extends Step<TestDescription, Program, ClosureConversionContext> { |
- const FastaCompile(); |
+ final bool strongMode; |
+ |
+ const FastaCompile(this.strongMode); |
String get name => "fasta compilation"; |
@@ -96,7 +107,7 @@ class FastaCompile |
platform.unbindCanonicalNames(); |
dillTarget.loader.appendLibraries(platform); |
KernelTarget sourceTarget = new KernelTarget(PhysicalFileSystem.instance, |
- dillTarget, context.uriTranslator, context.strongMode); |
+ dillTarget, context.uriTranslator, strongMode); |
Program p; |
try { |
@@ -111,20 +122,22 @@ class FastaCompile |
} |
} |
-class ClosureConversion |
- extends Step<Program, Program, ClosureConversionContext> { |
- const ClosureConversion(); |
+class Run extends Step<Uri, int, ClosureConversionContext> { |
+ const Run(); |
- String get name => "closure conversion"; |
+ String get name => "run"; |
- Future<Result<Program>> run( |
- Program program, ClosureConversionContext testContext) async { |
+ Future<Result<int>> run(Uri uri, ClosureConversionContext context) async { |
+ File generated = new File.fromUri(uri); |
+ StdioProcess process; |
try { |
- program = closure_conversion.transformProgram(program); |
- return pass(program); |
- } catch (e, s) { |
- return crash(e, s); |
+ process = |
+ await StdioProcess.run(context.vm.toFilePath(), [generated.path]); |
+ print(process.output); |
+ } finally { |
+ generated.parent.delete(recursive: true); |
} |
+ return process.toResult(); |
} |
} |