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.missing_file; | 7 library dart2js.test.missing_file; |
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 import "package:async_helper/async_helper.dart"; | |
12 | 11 |
13 import '../../../sdk/lib/_internal/compiler/compiler.dart' | 12 import '../../../sdk/lib/_internal/compiler/compiler.dart' |
14 show Diagnostic; | 13 show Diagnostic; |
15 import '../../../sdk/lib/_internal/compiler/implementation/dart2js.dart' | 14 import '../../../sdk/lib/_internal/compiler/implementation/dart2js.dart' |
16 show exitFunc, compileFunc, compile, diagnosticHandler; | 15 show exitFunc, compileFunc, compile, diagnosticHandler; |
17 import '../../../sdk/lib/_internal/compiler/implementation/source_file_provider.
dart' | 16 import '../../../sdk/lib/_internal/compiler/implementation/source_file_provider.
dart' |
18 show FormattingDiagnosticHandler; | 17 show FormattingDiagnosticHandler; |
19 | 18 |
20 class CollectingFormattingDiagnosticHandler | 19 class CollectingFormattingDiagnosticHandler |
21 implements FormattingDiagnosticHandler { | 20 implements FormattingDiagnosticHandler { |
(...skipping 16 matching lines...) Expand all Loading... |
38 messages.add([message, kind]); | 37 messages.add([message, kind]); |
39 } | 38 } |
40 | 39 |
41 void diagnosticHandler(Uri uri, int begin, int end, String message, kind) { | 40 void diagnosticHandler(Uri uri, int begin, int end, String message, kind) { |
42 messages.add([message, kind]); | 41 messages.add([message, kind]); |
43 } | 42 } |
44 | 43 |
45 void call(Uri uri, int begin, int end, String message, kind) { | 44 void call(Uri uri, int begin, int end, String message, kind) { |
46 diagnosticHandler(uri, begin, end, message, kind); | 45 diagnosticHandler(uri, begin, end, message, kind); |
47 } | 46 } |
| 47 |
| 48 String prefixMessage(String message, Diagnostic kind) { |
| 49 return message; |
| 50 } |
48 } | 51 } |
49 | 52 |
50 testOutputProvider(script, libraryRoot, packageRoot, inputProvider, handler, | 53 testOutputProvider(script, libraryRoot, packageRoot, inputProvider, handler, |
51 [options, outputProvider, environment]) { | 54 [options, outputProvider, environment]) { |
52 diagnosticHandler = new CollectingFormattingDiagnosticHandler(); | 55 diagnosticHandler = new CollectingFormattingDiagnosticHandler(); |
53 outputProvider("/non/existing/directory/should/fail/file", "js"); | 56 outputProvider("/non/existing/directory/should/fail/file", "js"); |
54 } | 57 } |
55 | 58 |
56 void main() { | 59 void main() { |
57 compileFunc = testOutputProvider; | 60 compileFunc = testOutputProvider; |
58 exitFunc = (exitCode) { | 61 exitFunc = (exitCode) { |
59 Expect.equals(1, diagnosticHandler.messages.length); | 62 CollectingFormattingDiagnosticHandler handler = diagnosticHandler; |
60 var message = diagnosticHandler.messages[0]; | 63 Expect.equals(1, handler.messages.length); |
| 64 var message = handler.messages[0]; |
61 Expect.isTrue(message[0].contains("Cannot open file")); | 65 Expect.isTrue(message[0].contains("Cannot open file")); |
62 Expect.equals(Diagnostic.ERROR, message[1]); | 66 Expect.equals(Diagnostic.ERROR, message[1]); |
63 Expect.equals(1, exitCode); | 67 Expect.equals(1, exitCode); |
64 exit(0); | 68 exit(0); |
65 }; | 69 }; |
66 compile(["foo.dart", "--out=bar.dart"]); | 70 compile(["foo.dart", "--out=bar.dart"]); |
67 } | 71 } |
OLD | NEW |