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'; | |
10 import 'dart:io' show exit; | 9 import 'dart:io' show exit; |
11 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
12 | 11 |
13 import 'package:compiler/compiler.dart' show Diagnostic; | 12 import 'package:compiler/compiler.dart' show Diagnostic; |
14 import 'package:compiler/compiler_new.dart' show OutputType; | 13 import 'package:compiler/compiler_new.dart' |
| 14 show CompilerDiagnostics, CompilerInput, CompilerOutput, OutputType; |
15 import 'package:compiler/src/dart2js.dart' | 15 import 'package:compiler/src/dart2js.dart' |
16 show exitFunc, compileFunc, compile, diagnosticHandler; | 16 show exitFunc, compileFunc, compile, diagnosticHandler; |
17 import 'package:compiler/src/source_file_provider.dart' | 17 import 'package:compiler/src/source_file_provider.dart' |
18 show FormattingDiagnosticHandler; | 18 show FormattingDiagnosticHandler; |
19 | 19 |
| 20 import 'package:compiler/src/options.dart' show CompilerOptions; |
| 21 |
20 class CollectingFormattingDiagnosticHandler | 22 class CollectingFormattingDiagnosticHandler |
21 implements FormattingDiagnosticHandler { | 23 implements FormattingDiagnosticHandler { |
22 final provider = null; | 24 final provider = null; |
23 bool showWarnings = true; | 25 bool showWarnings = true; |
24 bool showHints = true; | 26 bool showHints = true; |
25 bool verbose = true; | 27 bool verbose = true; |
26 bool isAborting = false; | 28 bool isAborting = false; |
27 bool enableColors = false; | 29 bool enableColors = false; |
28 bool throwOnError = false; | 30 bool throwOnError = false; |
29 var lastKind = null; | 31 var lastKind = null; |
(...skipping 19 matching lines...) Expand all Loading... |
49 | 51 |
50 String prefixMessage(String message, Diagnostic kind) { | 52 String prefixMessage(String message, Diagnostic kind) { |
51 return message; | 53 return message; |
52 } | 54 } |
53 | 55 |
54 int fatalCount; | 56 int fatalCount; |
55 | 57 |
56 int throwOnErrorCount; | 58 int throwOnErrorCount; |
57 } | 59 } |
58 | 60 |
59 testOutputProvider(options, input, diagnostics, output) { | 61 testOutputProvider(CompilerOptions options, CompilerInput input, |
| 62 CompilerDiagnostics diagnostics, CompilerOutput output) { |
60 diagnosticHandler = new CollectingFormattingDiagnosticHandler(); | 63 diagnosticHandler = new CollectingFormattingDiagnosticHandler(); |
61 output.createOutputSink( | 64 output.createOutputSink( |
62 "/non/existing/directory/should/fail/file", "js", OutputType.js); | 65 "/non/existing/directory/should/fail/file", "js", OutputType.js); |
63 } | 66 } |
64 | 67 |
65 void main() { | 68 void main() { |
66 compileFunc = testOutputProvider; | 69 compileFunc = testOutputProvider; |
67 exitFunc = (exitCode) { | 70 exitFunc = (exitCode) { |
68 CollectingFormattingDiagnosticHandler handler = diagnosticHandler; | 71 CollectingFormattingDiagnosticHandler handler = diagnosticHandler; |
69 Expect.equals(1, handler.messages.length); | 72 Expect.equals(1, handler.messages.length); |
70 var message = handler.messages[0]; | 73 var message = handler.messages[0]; |
71 Expect.isTrue(message[0].contains("Cannot open file")); | 74 Expect.isTrue(message[0].contains("Cannot open file")); |
72 Expect.equals(Diagnostic.ERROR, message[1]); | 75 Expect.equals(Diagnostic.ERROR, message[1]); |
73 Expect.equals(1, exitCode); | 76 Expect.equals(1, exitCode); |
74 exit(0); | 77 exit(0); |
75 }; | 78 }; |
76 compile(["foo.dart", "--out=bar.dart"]); | 79 compile(["foo.dart", "--out=bar.dart"]); |
77 } | 80 } |
OLD | NEW |