Chromium Code Reviews| 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; |
| +} |