| Index: pkg/kernel/test/reify/suite.dart
|
| diff --git a/pkg/kernel/test/reify/suite.dart b/pkg/kernel/test/reify/suite.dart
|
| index 378a768ea1d895b65daec3ac249a70771945f756..cfb5104a6da6719eaa3edca6730bd71e2fad041a 100644
|
| --- a/pkg/kernel/test/reify/suite.dart
|
| +++ b/pkg/kernel/test/reify/suite.dart
|
| @@ -6,14 +6,7 @@ library test.kernel.reify.suite;
|
|
|
| import 'dart:async' show Future;
|
|
|
| -import 'dart:io' show Directory, File, Platform;
|
| -
|
| -import 'package:analyzer/src/generated/sdk.dart' show DartSdk;
|
| -
|
| -import 'package:analyzer/src/kernel/loader.dart'
|
| - show DartLoader, DartOptions, createDartSdk;
|
| -
|
| -import 'package:kernel/class_hierarchy.dart' show ClosedWorldClassHierarchy;
|
| +import 'dart:io' show Platform, File;
|
|
|
| import 'package:kernel/core_types.dart' show CoreTypes;
|
|
|
| @@ -21,63 +14,57 @@ import 'package:kernel/target/targets.dart' show Target, TargetFlags, getTarget;
|
|
|
| import 'package:kernel/target/vmcc.dart' show VmClosureConvertedTarget;
|
|
|
| -import 'kernel_chain.dart'
|
| - show MatchExpectation, Print, ReadDill, SanityCheck, WriteDill;
|
| +import 'package:front_end/src/fasta/testing/patched_sdk_location.dart'
|
| + show computeDartVm, computePatchedSdk;
|
| +import 'package:front_end/src/fasta/testing/kernel_chain.dart'
|
| + show
|
| + Compile,
|
| + CompileContext,
|
| + MatchExpectation,
|
| + Print,
|
| + ReadDill,
|
| + Verify,
|
| + WriteDill;
|
|
|
| import 'package:testing/testing.dart'
|
| - show
|
| - Chain,
|
| - ChainContext,
|
| - Result,
|
| - StdioProcess,
|
| - Step,
|
| - TestDescription,
|
| - runMe;
|
| + show Chain, ChainContext, Result, StdioProcess, Step, runMe;
|
|
|
| import 'package:kernel/ast.dart' show Program;
|
|
|
| import 'package:kernel/transformations/generic_types_reification.dart'
|
| as generic_types_reification;
|
|
|
| -import 'package:package_config/discovery.dart' show loadPackagesFile;
|
| -
|
| -class TestContext extends ChainContext {
|
| +class TestContext extends ChainContext implements CompileContext {
|
| final Uri vm;
|
| + final Uri platformUri;
|
| + final Uri sdk;
|
|
|
| - final Uri packages;
|
| -
|
| - final DartOptions options;
|
| + @override
|
| + final Target target = new NotReifiedTarget(new TargetFlags(
|
| + strongMode: true,
|
| + kernelRuntime: Platform.script.resolve("../../runtime/")));
|
|
|
| - final DartSdk dartSdk;
|
| + // Strong mode is required to keep the type arguments in invocations of
|
| + // generic methods.
|
| + @override
|
| + bool get strongMode => true;
|
|
|
| final List<Step> steps;
|
|
|
| - TestContext(String sdk, this.vm, Uri packages, bool strongMode, this.dartSdk,
|
| - bool updateExpectations)
|
| - : packages = packages,
|
| - options = new DartOptions(
|
| - strongMode: strongMode,
|
| - sdk: sdk,
|
| - packagePath: packages.toFilePath()),
|
| - steps = <Step>[
|
| - const NotReifiedKernel(),
|
| + TestContext(this.vm, this.platformUri, this.sdk, bool updateExpectations)
|
| + : steps = <Step>[
|
| + const Compile(),
|
| const Print(),
|
| - const SanityCheck(),
|
| + const Verify(true),
|
| const GenericTypesReification(),
|
| const Print(),
|
| - const SanityCheck(),
|
| + const Verify(true),
|
| new MatchExpectation(".expect",
|
| updateExpectations: updateExpectations),
|
| const WriteDill(),
|
| const ReadDill(),
|
| const Run(),
|
| ];
|
| -
|
| - Future<DartLoader> createLoader() async {
|
| - return new DartLoader(
|
| - new Program(), options, await loadPackagesFile(packages),
|
| - dartSdk: dartSdk);
|
| - }
|
| }
|
|
|
| enum Environment {
|
| @@ -85,58 +72,13 @@ enum Environment {
|
| file,
|
| }
|
|
|
| -Future<String> getEnvironmentVariable(
|
| - String name, Environment kind, String undefined, notFound(String n)) async {
|
| - String result = Platform.environment[name];
|
| - if (result == null) {
|
| - throw undefined;
|
| - }
|
| - switch (kind) {
|
| - case Environment.directory:
|
| - if (!await new Directory(result).exists()) throw notFound(result);
|
| - break;
|
| -
|
| - case Environment.file:
|
| - if (!await new File(result).exists()) throw notFound(result);
|
| - break;
|
| - }
|
| - return result;
|
| -}
|
| -
|
| -Future<bool> fileExists(Uri base, String path) async {
|
| - return await new File.fromUri(base.resolve(path)).exists();
|
| -}
|
| -
|
| Future<TestContext> createContext(
|
| Chain suite, Map<String, String> environment) async {
|
| - const String suggestion = """Try building the patched SDK by running
|
| - 'tools/build.py patched_sdk'""";
|
| -
|
| - // TODO(karlklose): The path is different on MacOS.
|
| - String sdk = "out/DebugX64/patched_sdk/";
|
| - Uri sdkUri = Uri.base.resolve(sdk);
|
| - const String asyncDart = "lib/async/async.dart";
|
| - if (!await fileExists(sdkUri, asyncDart)) {
|
| - throw "Couldn't find the patched SDK. $suggestion";
|
| - }
|
| - const String asyncSources = "lib/async/async_sources.gypi";
|
| - if (await fileExists(sdkUri, asyncSources)) {
|
| - throw "Found '$asyncSources' in '$sdk', so it isn't a patched SDK. "
|
| - "$suggestion";
|
| - }
|
| -
|
| - // TODO(karlklose): select the VM based on the mode.
|
| - Uri vm = Uri.base.resolve("out/ReleaseX64/dart");
|
| -
|
| - Uri packages = Uri.base.resolve(".packages");
|
| - // Strong mode is required to keep the type arguments in invocations of
|
| - // generic methods.
|
| - bool strongMode = true;
|
| - bool updateExpectations = const String.fromEnvironment("updateExpectations",
|
| - defaultValue: "false") ==
|
| - "true";
|
| - return new TestContext(sdk, vm, packages, strongMode,
|
| - createDartSdk(sdk, strongMode: strongMode), updateExpectations);
|
| + Uri sdk = await computePatchedSdk();
|
| + Uri vm = computeDartVm(sdk);
|
| + Uri platform = sdk.resolve('platform.dill');
|
| + bool updateExpectations = environment["updateExpectations"] == "true";
|
| + return new TestContext(vm, platform, sdk, updateExpectations);
|
| }
|
|
|
| // [NotReifiedTarget] is intended to work as the [Target] class that
|
| @@ -172,41 +114,6 @@ class NotReifiedTarget extends VmClosureConvertedTarget {
|
| }
|
| }
|
|
|
| -class NotReifiedKernel extends Step<TestDescription, Program, TestContext> {
|
| - const NotReifiedKernel();
|
| -
|
| - String get name => "kernel";
|
| -
|
| - Future<Result<Program>> run(
|
| - TestDescription description, TestContext testContext) async {
|
| - try {
|
| - DartLoader loader = await testContext.createLoader();
|
| -
|
| - // Strong mode is required to keep the type arguments in invocations of
|
| - // generic methods.
|
| - Target target = new NotReifiedTarget(new TargetFlags(
|
| - strongMode: true,
|
| - kernelRuntime: Platform.script.resolve("../../runtime/")));
|
| -
|
| - String path = description.file.path;
|
| - Uri uri = Uri.base.resolve(path);
|
| - loader.loadProgram(uri, target: target);
|
| - var program = loader.program;
|
| - for (var error in loader.errors) {
|
| - return fail(program, "$error");
|
| - }
|
| - var coreTypes = new CoreTypes(program);
|
| - var hierarchy = new ClosedWorldClassHierarchy(program);
|
| - target
|
| - ..performModularTransformationsOnProgram(coreTypes, hierarchy, program)
|
| - ..performGlobalTransformations(coreTypes, program);
|
| - return pass(program);
|
| - } catch (e, s) {
|
| - return crash(e, s);
|
| - }
|
| - }
|
| -}
|
| -
|
| class GenericTypesReification extends Step<Program, Program, TestContext> {
|
| const GenericTypesReification();
|
|
|
| @@ -228,12 +135,17 @@ class Run extends Step<Uri, int, TestContext> {
|
|
|
| String get name => "run";
|
|
|
| + bool get isAsync => true;
|
| +
|
| + bool get isRuntime => true;
|
| +
|
| Future<Result<int>> run(Uri uri, TestContext context) async {
|
| File generated = new File.fromUri(uri);
|
| StdioProcess process;
|
| try {
|
| - process =
|
| - await StdioProcess.run(context.vm.toFilePath(), [generated.path]);
|
| + var sdkPath = context.sdk.toFilePath();
|
| + var args = ['--kernel-binaries=$sdkPath', generated.path];
|
| + process = await StdioProcess.run(context.vm.toFilePath(), args);
|
| print(process.output);
|
| } finally {
|
| generated.parent.delete(recursive: true);
|
|
|