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

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

Issue 2865693002: Create closed world for hello world using .dill file (Closed)
Patch Set: Update and fix. 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
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 420f81a645afe58e4af8028621169739e9a5cd2e..0a81609cd18c74f66f38d8d3944bf99360544a76 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();
@@ -135,3 +137,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/15 17:05:50 delete commented code
Johnni Winther 2017/05/16 08:29:54 Done.
+ '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;
+}

Powered by Google App Engine
This is Rietveld 408576698