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

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

Issue 2690243003: Clone platform in memory when testing. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/testing/suite.dart
diff --git a/pkg/front_end/lib/src/fasta/testing/suite.dart b/pkg/front_end/lib/src/fasta/testing/suite.dart
index c651cb85577180b897cecb4fb2907dd6b401ea5f..a5e94376af3644b5ac6bb31b3b01266b4e892023 100644
--- a/pkg/front_end/lib/src/fasta/testing/suite.dart
+++ b/pkg/front_end/lib/src/fasta/testing/suite.dart
@@ -10,6 +10,9 @@ import 'dart:async' show
import 'dart:convert' show
JSON;
+import 'dart:typed_data' show
+ Uint8List;
+
import 'package:analyzer/src/generated/sdk.dart' show
DartSdk;
@@ -17,6 +20,18 @@ import 'package:kernel/ast.dart' show
Library,
Program;
+import 'package:kernel/binary/ast_from_binary.dart' show
+ BinaryBuilder;
+
+import 'package:kernel/binary/ast_to_binary.dart' show
+ BinaryPrinter;
+
+import 'package:kernel/binary/loader.dart' show
+ BinaryLoader;
+
+import 'package:kernel/kernel.dart' show
+ Repository;
+
import 'package:kernel/analyzer/loader.dart' show
DartLoader;
@@ -36,11 +51,12 @@ import '../errors.dart' show
InputError;
import 'kernel_chain.dart' show
+ BytesCollector,
MatchExpectation,
Print,
Run,
- Verify,
TestContext,
+ Verify,
WriteDill;
import '../ticker.dart' show
@@ -97,7 +113,7 @@ class FeContext extends TestContext {
final ExpectationSet expectationSet =
new ExpectationSet.fromJsonList(JSON.decode(EXPECTATIONS));
- Future<Program> platform;
+ Future<Uint8List> platform;
FeContext(Uri sdk, Uri vm, Uri packages, bool strongMode,
DartSdk dartSdk, bool updateExpectations, this.uriTranslator,
@@ -119,24 +135,29 @@ class FeContext extends TestContext {
}
}
- Future<Program> createPlatform() {
- return platform ??= new Future<Program>(() async {
+ Future<Program> createPlatform() async {
+ platform ??= new Future<Uint8List>(() async {
DartLoader loader = await createLoader();
Target target = getTarget(
"vm", new TargetFlags(strongMode: options.strongMode));
Program program = loader.loadProgram(
Uri.base.resolve("pkg/fasta/test/platform.dart"), target: target);
- target.performModularTransformations(program);
- target.performGlobalTransformations(program);
if (loader.errors.isNotEmpty) {
throw loader.errors.join("\n");
}
Library mainLibrary = program.mainMethod.enclosingLibrary;
program.uriToSource.remove(mainLibrary.fileUri);
- return new Program(
+ Program platform = new Program(
program.libraries.where((Library l) => l != mainLibrary).toList(),
program.uriToSource);
+ target.performModularTransformations(platform);
+ target.performGlobalTransformations(platform);
+ BytesCollector sink = new BytesCollector();
+ new BinaryPrinter(sink).writeProgramFile(platform);
+ return sink.collect();
});
+ BinaryLoader loader = new BinaryLoader(new Repository());
+ return new BinaryBuilder(loader, await platform).readProgramFile();
}
static Future<FeContext> create(Chain suite, Map<String, String> environment,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698