OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // Test that the compiler can handle imports when package root has not been set. | 5 // Test that the compiler can handle imports when package root has not been set. |
6 | 6 |
7 library dart2js.test.bad_output_io; | 7 library dart2js.test.bad_output_io; |
8 | 8 |
| 9 import 'dart:async' show Future; |
9 import 'dart:io' show exit; | 10 import 'dart:io' show exit; |
10 import 'package:expect/expect.dart'; | 11 import 'package:expect/expect.dart'; |
11 | 12 |
12 import 'package:compiler/compiler.dart' show Diagnostic; | 13 import 'package:compiler/compiler.dart' show Diagnostic; |
13 import 'package:compiler/compiler_new.dart' | 14 import 'package:compiler/compiler_new.dart' |
14 show CompilerDiagnostics, CompilerInput, CompilerOutput, OutputType; | 15 show |
| 16 CompilationResult, |
| 17 CompilerDiagnostics, |
| 18 CompilerInput, |
| 19 CompilerOutput, |
| 20 OutputType; |
15 import 'package:compiler/src/dart2js.dart' | 21 import 'package:compiler/src/dart2js.dart' |
16 show exitFunc, compileFunc, compile, diagnosticHandler; | 22 show exitFunc, compileFunc, compile, diagnosticHandler; |
17 import 'package:compiler/src/source_file_provider.dart' | 23 import 'package:compiler/src/source_file_provider.dart' |
18 show FormattingDiagnosticHandler; | 24 show FormattingDiagnosticHandler; |
19 | 25 |
20 import 'package:compiler/src/options.dart' show CompilerOptions; | 26 import 'package:compiler/src/options.dart' show CompilerOptions; |
21 | 27 |
22 class CollectingFormattingDiagnosticHandler | 28 class CollectingFormattingDiagnosticHandler |
23 implements FormattingDiagnosticHandler { | 29 implements FormattingDiagnosticHandler { |
24 final provider = null; | 30 final provider = null; |
(...skipping 26 matching lines...) Expand all Loading... |
51 | 57 |
52 String prefixMessage(String message, Diagnostic kind) { | 58 String prefixMessage(String message, Diagnostic kind) { |
53 return message; | 59 return message; |
54 } | 60 } |
55 | 61 |
56 int fatalCount; | 62 int fatalCount; |
57 | 63 |
58 int throwOnErrorCount; | 64 int throwOnErrorCount; |
59 } | 65 } |
60 | 66 |
61 testOutputProvider(CompilerOptions options, CompilerInput input, | 67 Future<CompilationResult> testOutputProvider( |
62 CompilerDiagnostics diagnostics, CompilerOutput output) { | 68 CompilerOptions options, |
| 69 CompilerInput input, |
| 70 CompilerDiagnostics diagnostics, |
| 71 CompilerOutput output) { |
63 diagnosticHandler = new CollectingFormattingDiagnosticHandler(); | 72 diagnosticHandler = new CollectingFormattingDiagnosticHandler(); |
64 output.createOutputSink( | 73 output.createOutputSink( |
65 "/non/existing/directory/should/fail/file", "js", OutputType.js); | 74 "/non/existing/directory/should/fail/file", "js", OutputType.js); |
| 75 return null; |
66 } | 76 } |
67 | 77 |
68 void main() { | 78 void main() { |
69 compileFunc = testOutputProvider; | 79 compileFunc = testOutputProvider; |
70 exitFunc = (exitCode) { | 80 exitFunc = (exitCode) { |
71 CollectingFormattingDiagnosticHandler handler = diagnosticHandler; | 81 CollectingFormattingDiagnosticHandler handler = diagnosticHandler; |
72 Expect.equals(1, handler.messages.length); | 82 Expect.equals(1, handler.messages.length); |
73 var message = handler.messages[0]; | 83 var message = handler.messages[0]; |
74 Expect.isTrue(message[0].contains("Cannot open file")); | 84 Expect.isTrue(message[0].contains("Cannot open file")); |
75 Expect.equals(Diagnostic.ERROR, message[1]); | 85 Expect.equals(Diagnostic.ERROR, message[1]); |
76 Expect.equals(1, exitCode); | 86 Expect.equals(1, exitCode); |
77 exit(0); | 87 exit(0); |
78 }; | 88 }; |
79 compile(["foo.dart", "--out=bar.dart"]); | 89 compile(["foo.dart", "--out=bar.dart"]); |
80 } | 90 } |
OLD | NEW |