OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'dart:async' show Future; | 5 import 'dart:async' show Future; |
6 | 6 |
7 import 'dart:io' show Directory, File, Platform; | 7 import 'dart:io' show Directory, File, Platform; |
8 | 8 |
9 import 'dart:isolate' show Isolate; | 9 import 'dart:isolate' show Isolate; |
10 | 10 |
11 import 'package:async_helper/async_helper.dart' show asyncEnd, asyncStart; | 11 import 'package:async_helper/async_helper.dart' show asyncEnd, asyncStart; |
12 | 12 |
13 import 'package:front_end/src/fasta/testing/kernel_chain.dart' | 13 import 'package:front_end/src/fasta/testing/kernel_chain.dart' |
14 show computePatchedSdk; | 14 show computePatchedSdk; |
15 | 15 |
16 import 'package:testing/testing.dart' show StdioProcess; | 16 import 'package:testing/testing.dart' show StdioProcess; |
17 | 17 |
18 import 'package:kernel/binary/ast_from_binary.dart' show BinaryBuilder; | 18 import 'package:kernel/binary/ast_from_binary.dart' show BinaryBuilder; |
19 | 19 |
20 import 'package:kernel/ast.dart' show Program; | 20 import 'package:kernel/ast.dart' show Program; |
21 | 21 |
22 import 'package:kernel/text/ast_to_text.dart' show programToString; | 22 import 'package:kernel/text/ast_to_text.dart' show programToString; |
23 | 23 |
24 Future main() async { | 24 Future main() async { |
25 asyncStart(); | 25 asyncStart(); |
26 Uri sourceCompiler = Uri.base.resolve("pkg/front_end/tool/fasta/compile.dart")
; | 26 Uri sourceCompiler = |
| 27 Uri.base.resolve("pkg/front_end/tool/fasta/compile.dart"); |
27 Uri outline = Uri.base.resolve("pkg/front_end/tool/fasta/outline.dart"); | 28 Uri outline = Uri.base.resolve("pkg/front_end/tool/fasta/outline.dart"); |
28 Uri packages = await Isolate.packageConfig; | 29 Uri packages = await Isolate.packageConfig; |
29 Directory tmp = await Directory.systemTemp.createTemp("fasta_bootstrap"); | 30 Directory tmp = await Directory.systemTemp.createTemp("fasta_bootstrap"); |
30 Uri compiledOnceOutput = tmp.uri.resolve("fasta1.dill"); | 31 Uri compiledOnceOutput = tmp.uri.resolve("fasta1.dill"); |
31 Uri compiledTwiceOutput = tmp.uri.resolve("fasta2.dill"); | 32 Uri compiledTwiceOutput = tmp.uri.resolve("fasta2.dill"); |
32 Uri outlineOutput = tmp.uri.resolve("outline.dill"); | 33 Uri outlineOutput = tmp.uri.resolve("outline.dill"); |
33 try { | 34 try { |
34 await runCompiler(sourceCompiler, sourceCompiler, compiledOnceOutput); | 35 await runCompiler(sourceCompiler, sourceCompiler, compiledOnceOutput); |
35 await runCompiler(compiledOnceOutput, sourceCompiler, compiledTwiceOutput); | 36 await runCompiler(compiledOnceOutput, sourceCompiler, compiledTwiceOutput); |
36 await compare(compiledOnceOutput, compiledTwiceOutput); | 37 await compare(compiledOnceOutput, compiledTwiceOutput); |
(...skipping 16 matching lines...) Expand all Loading... |
53 Uri patchedSdk = await computePatchedSdk(); | 54 Uri patchedSdk = await computePatchedSdk(); |
54 Uri dartVm = Uri.base.resolve(Platform.resolvedExecutable); | 55 Uri dartVm = Uri.base.resolve(Platform.resolvedExecutable); |
55 StdioProcess result = await StdioProcess.run(dartVm.toFilePath(), <String>[ | 56 StdioProcess result = await StdioProcess.run(dartVm.toFilePath(), <String>[ |
56 "-c", | 57 "-c", |
57 compiler.toFilePath(), | 58 compiler.toFilePath(), |
58 "--compile-sdk=${patchedSdk.toFilePath()}", | 59 "--compile-sdk=${patchedSdk.toFilePath()}", |
59 "--output=${output.toFilePath()}", | 60 "--output=${output.toFilePath()}", |
60 "--verify", | 61 "--verify", |
61 input.toFilePath(), | 62 input.toFilePath(), |
62 ]); | 63 ]); |
63 print(result.output); | 64 if (result.output.isNotEmpty) { |
| 65 print(result.output); |
| 66 } |
64 if (result.exitCode != 0) { | 67 if (result.exitCode != 0) { |
65 throw "Compilation failed."; | 68 throw "Compilation failed."; |
66 } | 69 } |
67 } | 70 } |
68 | 71 |
69 Future compare(Uri a, Uri b, {bool silent: false}) async { | 72 Future compare(Uri a, Uri b, {bool silent: false}) async { |
70 List<int> bytesA = await new File.fromUri(a).readAsBytes(); | 73 List<int> bytesA = await new File.fromUri(a).readAsBytes(); |
71 List<int> bytesB = await new File.fromUri(b).readAsBytes(); | 74 List<int> bytesB = await new File.fromUri(b).readAsBytes(); |
72 if (bytesA.length == bytesB.length) { | 75 if (bytesA.length == bytesB.length) { |
73 bool same = true; | 76 bool same = true; |
(...skipping 29 matching lines...) Expand all Loading... |
103 } | 106 } |
104 | 107 |
105 class ComparisonFailed { | 108 class ComparisonFailed { |
106 final Uri a; | 109 final Uri a; |
107 final Uri b; | 110 final Uri b; |
108 | 111 |
109 ComparisonFailed(this.a, this.b); | 112 ComparisonFailed(this.a, this.b); |
110 | 113 |
111 toString() => "Error: $a is different from $b"; | 114 toString() => "Error: $a is different from $b"; |
112 } | 115 } |
OLD | NEW |