OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 // TODO(ahe): Copied from closure_conversion branch of kernel, remove this file | 5 // TODO(ahe): Copied from closure_conversion branch of kernel, remove this file |
6 // when closure_conversion is merged with master. | 6 // when closure_conversion is merged with master. |
7 | 7 |
8 library fasta.testing.kernel_chain; | 8 library fasta.testing.kernel_chain; |
9 | 9 |
10 import 'dart:async' show Future; | 10 import 'dart:async' show Future; |
11 | 11 |
12 import 'dart:io' show Directory, File, IOSink; | 12 import 'dart:io' show Directory, File, IOSink; |
13 | 13 |
14 import 'dart:typed_data' show Uint8List; | 14 import 'dart:typed_data' show Uint8List; |
15 | 15 |
16 import 'package:kernel/kernel.dart' show loadProgramFromBinary; | 16 import 'package:kernel/kernel.dart' show loadProgramFromBinary; |
17 | 17 |
18 import 'package:kernel/target/targets.dart' show Target; | 18 import 'package:kernel/target/targets.dart' show Target; |
19 | 19 |
20 import 'package:kernel/text/ast_to_text.dart' show Printer; | 20 import 'package:kernel/text/ast_to_text.dart' show Printer; |
21 | 21 |
22 import 'package:testing/testing.dart' show Result, StdioProcess, Step; | 22 import 'package:testing/testing.dart' show Result, StdioProcess, Step; |
23 | 23 |
24 import 'package:kernel/ast.dart' show Library, Program; | 24 import 'package:kernel/ast.dart' show Library, Program; |
25 | 25 |
26 import '../kernel/verifier.dart' show verifyProgram; | 26 import '../kernel/verifier.dart' show verifyProgram; |
27 | 27 |
28 import '../compiler_command_line.dart'; | 28 import '../compiler_context.dart'; |
29 | 29 |
30 import 'package:kernel/binary/ast_to_binary.dart' show BinaryPrinter; | 30 import 'package:kernel/binary/ast_to_binary.dart' show BinaryPrinter; |
31 | 31 |
32 import 'package:kernel/binary/ast_from_binary.dart' show BinaryBuilder; | 32 import 'package:kernel/binary/ast_from_binary.dart' show BinaryBuilder; |
33 | 33 |
34 import 'package:testing/testing.dart' | 34 import 'package:testing/testing.dart' |
35 show ChainContext, Result, StdioProcess, Step, TestDescription; | 35 show ChainContext, Result, StdioProcess, Step, TestDescription; |
36 | 36 |
37 import 'package:kernel/ast.dart' show Program; | 37 import 'package:kernel/ast.dart' show Program; |
38 | 38 |
(...skipping 21 matching lines...) Expand all Loading... |
60 } | 60 } |
61 | 61 |
62 class Verify extends Step<Program, Program, ChainContext> { | 62 class Verify extends Step<Program, Program, ChainContext> { |
63 final bool fullCompile; | 63 final bool fullCompile; |
64 | 64 |
65 const Verify(this.fullCompile); | 65 const Verify(this.fullCompile); |
66 | 66 |
67 String get name => "verify"; | 67 String get name => "verify"; |
68 | 68 |
69 Future<Result<Program>> run(Program program, ChainContext context) async { | 69 Future<Result<Program>> run(Program program, ChainContext context) async { |
70 return await CompilerCommandLine.withGlobalOptions("", [""], (_) async { | 70 return await CompilerContext.runWithDefaultOptions((_) async { |
71 var errors = verifyProgram(program, isOutline: !fullCompile); | 71 var errors = verifyProgram(program, isOutline: !fullCompile); |
72 if (errors.isEmpty) { | 72 if (errors.isEmpty) { |
73 return pass(program); | 73 return pass(program); |
74 } else { | 74 } else { |
75 return new Result<Program>( | 75 return new Result<Program>( |
76 null, context.expectationSet["VerificationError"], errors, null); | 76 null, context.expectationSet["VerificationError"], errors, null); |
77 } | 77 } |
78 }); | 78 }); |
79 } | 79 } |
80 } | 80 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 /// Most options are hard-coded, but if necessary they could be moved to the | 184 /// Most options are hard-coded, but if necessary they could be moved to the |
185 /// [CompileContext] object in the future. | 185 /// [CompileContext] object in the future. |
186 class Compile extends Step<TestDescription, Program, CompileContext> { | 186 class Compile extends Step<TestDescription, Program, CompileContext> { |
187 const Compile(); | 187 const Compile(); |
188 | 188 |
189 String get name => "fasta compilation"; | 189 String get name => "fasta compilation"; |
190 | 190 |
191 Future<Result<Program>> run( | 191 Future<Result<Program>> run( |
192 TestDescription description, CompileContext context) async { | 192 TestDescription description, CompileContext context) async { |
193 Result<Program> result; | 193 Result<Program> result; |
194 reportError(CompilationError error) { | 194 reportError(CompilationMessage error) { |
195 result ??= fail(null, error.message); | 195 result ??= fail(null, error.message); |
196 } | 196 } |
197 | 197 |
198 Uri sdk = await computePatchedSdk(); | 198 Uri sdk = await computePatchedSdk(); |
199 var options = new CompilerOptions() | 199 var options = new CompilerOptions() |
200 ..sdkRoot = sdk | 200 ..sdkRoot = sdk |
201 ..compileSdk = true | 201 ..compileSdk = true |
202 ..packagesFileUri = Uri.base.resolve('.packages') | 202 ..packagesFileUri = Uri.base.resolve('.packages') |
203 ..strongMode = context.strongMode | 203 ..strongMode = context.strongMode |
204 ..onError = reportError; | 204 ..onError = reportError; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 253 |
254 Future openWrite(Uri uri, f(IOSink sink)) async { | 254 Future openWrite(Uri uri, f(IOSink sink)) async { |
255 IOSink sink = new File.fromUri(uri).openWrite(); | 255 IOSink sink = new File.fromUri(uri).openWrite(); |
256 try { | 256 try { |
257 await f(sink); | 257 await f(sink); |
258 } finally { | 258 } finally { |
259 await sink.close(); | 259 await sink.close(); |
260 } | 260 } |
261 print("Wrote $uri"); | 261 print("Wrote $uri"); |
262 } | 262 } |
OLD | NEW |