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:io' show exit; | 9 import 'dart:io' show exit; |
10 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
11 | 11 |
12 import 'package:compiler/compiler.dart' | 12 import 'package:compiler/compiler.dart' show Diagnostic; |
13 show Diagnostic; | |
14 import 'package:compiler/src/dart2js.dart' | 13 import 'package:compiler/src/dart2js.dart' |
15 show exitFunc, compileFunc, compile, diagnosticHandler; | 14 show exitFunc, compileFunc, compile, diagnosticHandler; |
16 import 'package:compiler/src/source_file_provider.dart' | 15 import 'package:compiler/src/source_file_provider.dart' |
17 show FormattingDiagnosticHandler; | 16 show FormattingDiagnosticHandler; |
18 | 17 |
19 class CollectingFormattingDiagnosticHandler | 18 class CollectingFormattingDiagnosticHandler |
20 implements FormattingDiagnosticHandler { | 19 implements FormattingDiagnosticHandler { |
21 | |
22 final provider = null; | 20 final provider = null; |
23 bool showWarnings = true; | 21 bool showWarnings = true; |
24 bool showHints = true; | 22 bool showHints = true; |
25 bool verbose = true; | 23 bool verbose = true; |
26 bool isAborting = false; | 24 bool isAborting = false; |
27 bool enableColors = false; | 25 bool enableColors = false; |
28 bool throwOnError = false; | 26 bool throwOnError = false; |
29 var lastKind = null; | 27 var lastKind = null; |
30 | 28 |
31 final int FATAL = 0; | 29 final int FATAL = 0; |
32 final int INFO = 1; | 30 final int INFO = 1; |
33 | 31 |
34 final messages = []; | 32 final messages = []; |
35 | 33 |
36 void info(var message, [kind]) { | 34 void info(var message, [kind]) { |
37 messages.add([message, kind]); | 35 messages.add([message, kind]); |
38 } | 36 } |
39 | 37 |
40 @override | 38 @override |
41 void report(var code, Uri uri, int begin, int end, String message, kind) { | 39 void report(var code, Uri uri, int begin, int end, String message, kind) { |
42 messages.add([message, kind]); | 40 messages.add([message, kind]); |
43 } | 41 } |
44 | 42 |
45 @override | 43 @override |
46 void call(Uri uri, int begin, int end, String message, kind) { | 44 void call(Uri uri, int begin, int end, String message, kind) { |
47 report(null, uri, begin, end, message, kind); | 45 report(null, uri, begin, end, message, kind); |
(...skipping 19 matching lines...) Expand all Loading... |
67 CollectingFormattingDiagnosticHandler handler = diagnosticHandler; | 65 CollectingFormattingDiagnosticHandler handler = diagnosticHandler; |
68 Expect.equals(1, handler.messages.length); | 66 Expect.equals(1, handler.messages.length); |
69 var message = handler.messages[0]; | 67 var message = handler.messages[0]; |
70 Expect.isTrue(message[0].contains("Cannot open file")); | 68 Expect.isTrue(message[0].contains("Cannot open file")); |
71 Expect.equals(Diagnostic.ERROR, message[1]); | 69 Expect.equals(Diagnostic.ERROR, message[1]); |
72 Expect.equals(1, exitCode); | 70 Expect.equals(1, exitCode); |
73 exit(0); | 71 exit(0); |
74 }; | 72 }; |
75 compile(["foo.dart", "--out=bar.dart"]); | 73 compile(["foo.dart", "--out=bar.dart"]); |
76 } | 74 } |
OLD | NEW |