Chromium Code Reviews| Index: pkg/front_end/test/fasta/bootstrap_test.dart |
| diff --git a/pkg/front_end/test/fasta/bootstrap_test.dart b/pkg/front_end/test/fasta/bootstrap_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..759fd6145b909224a57f4144abeafbbce39e9863 |
| --- /dev/null |
| +++ b/pkg/front_end/test/fasta/bootstrap_test.dart |
| @@ -0,0 +1,64 @@ |
| +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +import 'dart:async' show |
| + Future; |
| + |
| +import 'dart:io' show |
| + Directory, |
| + Platform; |
| + |
| +import 'dart:isolate' show |
| + Isolate; |
| + |
| +import 'package:async_helper/async_helper.dart' show |
| + asyncEnd, |
| + asyncStart; |
| + |
| +import 'package:front_end/src/fasta/testing/kernel_chain.dart' show |
| + computePatchedSdk; |
| + |
| +import 'package:testing/testing.dart' show |
| + StdioProcess; |
| + |
| +Future main() async { |
| + asyncStart(); |
| + Uri sourceCompiler = await Isolate.resolvePackageUri( |
| + Uri.parse("package:front_end/src/fasta/bin/compile.dart")); |
| + Uri packages = await Isolate.packageConfig; |
| + try { |
| + Directory tmp = await Directory.systemTemp.createTemp("fasta_bootstrap"); |
| + Uri compiledOnceCompiler = tmp.uri.resolve("fasta1.dill"); |
|
karlklose
2017/02/28 11:47:37
Why are these names ending in compiler?
ahe
2017/02/28 11:52:35
Because it means "compiler that was compiled once"
|
| + Uri compiledTwiceCompiler = tmp.uri.resolve("fasta2.dill"); |
| + try { |
| + await runCompiler(sourceCompiler, sourceCompiler, compiledOnceCompiler); |
| + await runCompiler( |
| + compiledOnceCompiler, sourceCompiler, compiledTwiceCompiler); |
| + } finally { |
| + await tmp.delete(recursive: true); |
| + } |
| + } finally { |
| + asyncEnd(); |
| + } |
| +} |
| + |
| +Future runCompiler(Uri compiler, Uri input, Uri output) async { |
| + Uri patchedSdk = await computePatchedSdk(); |
| + Uri dartVm = Uri.base.resolve(Platform.resolvedExecutable); |
| + StdioProcess result = await StdioProcess.run( |
| + dartVm.toFilePath(), |
| + <String>[ |
| + compiler.toFilePath(), |
| + "--compile-sdk=${patchedSdk.toFilePath()}", |
| + "--output=${output.toFilePath()}", |
| + input.toFilePath(), |
| + ]); |
| + print(result.output); |
| + if (result.exitCode != 1) { |
| + // TODO(ahe): Due to known errors in the VM's patch files, this compiler |
| + // should report an error. Also, it may not be able to compile everything |
| + // yet. |
| + throw "Compilation failed."; |
| + } |
| +} |