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

Unified Diff: tests/compiler/dart2js/kernel/compiler_helper.dart

Issue 2865693002: Create closed world for hello world using .dill file (Closed)
Patch Set: Created 3 years, 7 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 | « tests/compiler/dart2js/kernel/closed_world_from_dill_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/kernel/compiler_helper.dart
diff --git a/tests/compiler/dart2js/kernel/compiler_helper.dart b/tests/compiler/dart2js/kernel/compiler_helper.dart
index 0adcd290f516c11fcbf1bbe95f068224e693ba4d..f11f81f9dbcbe1bfe304f4fdca1f6dec8d34bf89 100644
--- a/tests/compiler/dart2js/kernel/compiler_helper.dart
+++ b/tests/compiler/dart2js/kernel/compiler_helper.dart
@@ -7,6 +7,7 @@
library dart2js.kernel.compiler_helper;
import 'dart:async';
+import 'dart:io';
import 'package:compiler/src/commandline_options.dart';
import 'package:compiler/src/common.dart';
@@ -22,6 +23,7 @@ import 'package:compiler/src/util/util.dart';
import 'package:expect/expect.dart';
import 'package:kernel/ast.dart' as ir;
import '../memory_compiler.dart';
+import '../../../../pkg/compiler/tool/generate_kernel.dart' as generate;
typedef Future<Compiler> CompileFunction();
@@ -134,3 +136,48 @@ class MemoryDillLibraryLoaderTask extends DillLibraryLoaderTask {
return createLoadedLibraries(program);
}
}
+
+Future<Compiler> compileWithDill(
+ Uri entryPoint, Map<String, String> memorySourceFiles,
+ {bool printSteps: false}) async {
+ if (memorySourceFiles.isNotEmpty) {
+ Directory dir = await Directory.systemTemp.createTemp('dart2js-with-dill');
+ if (printSteps) {
+ print('--- create temp directory $dir -------------------------------');
+ }
+ memorySourceFiles.forEach((String name, String source) {
+ new File.fromUri(dir.uri.resolve(name)).writeAsStringSync(source);
+ });
+ entryPoint = dir.uri.resolve(entryPoint.path);
+ }
+ if (printSteps) {
+ print('---- generate dill -----------------------------------------------');
+ }
+
+ Uri dillFile = Uri.parse('$entryPoint.dill');
+ /*ProcessResult processResult = await Process.runSync(
Siggi Cherem (dart-lang) 2017/05/05 17:55:57 delete comment?
+ 'pkg/compiler/tool/generate_kernel',
+ ['--platform=out/ReleaseX64/patched_dart2js_sdk/platform.dill',
+ '$entryPoint']);
+ if (processResult.exitCode != 0) {
+ print(processResult.stderr);
+ exit(processResult.exitCode);
+ }*/
+ await generate.main([
+ '--platform=out/ReleaseX64/patched_dart2js_sdk/platform.dill',
+ '$entryPoint'
+ ]);
+
+ if (printSteps) {
+ print('---- closed world from dill $dillFile ----------------------------');
+ }
+ Compiler compiler = compilerFor(entryPoint: dillFile, options: [
+ Flags.analyzeOnly,
+ Flags.enableAssertMessage,
+ Flags.loadFromDill
+ ]);
+ ElementResolutionWorldBuilder.useInstantiationMap = true;
+ compiler.resolution.retainCachesForTesting = true;
+ await compiler.run(dillFile);
+ return compiler;
+}
« no previous file with comments | « tests/compiler/dart2js/kernel/closed_world_from_dill_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698