OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library unittest.unittest; | 5 library unittest.unittest; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
10 | 10 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 if (new File(path).existsSync()) return loader.loadFile(path); | 71 if (new File(path).existsSync()) return loader.loadFile(path); |
72 throw new LoadException(path, 'Does not exist.'); | 72 throw new LoadException(path, 'Does not exist.'); |
73 })); | 73 })); |
74 }).then((suites) { | 74 }).then((suites) { |
75 var reporter = new CompactReporter(flatten(suites), color: color); | 75 var reporter = new CompactReporter(flatten(suites), color: color); |
76 return reporter.run().then((success) { | 76 return reporter.run().then((success) { |
77 exitCode = success ? 0 : 1; | 77 exitCode = success ? 0 : 1; |
78 }).whenComplete(() => reporter.close()); | 78 }).whenComplete(() => reporter.close()); |
79 }).catchError((error, stackTrace) { | 79 }).catchError((error, stackTrace) { |
80 if (error is LoadException) { | 80 if (error is LoadException) { |
81 // TODO(nweiz): color this message? | 81 stderr.writeln(error.toString(color: color)); |
82 stderr.writeln(getErrorMessage(error)); | |
83 | 82 |
84 // Only print stack traces for load errors that come from the user's | 83 // Only print stack traces for load errors that come from the user's |
85 if (error.innerError is! IOException && | 84 if (error.innerError is! IOException && |
86 error.innerError is! IsolateSpawnException && | 85 error.innerError is! IsolateSpawnException && |
| 86 error.innerError is! FormatException && |
87 error.innerError is! String) { | 87 error.innerError is! String) { |
88 stderr.write(terseChain(stackTrace)); | 88 stderr.write(terseChain(stackTrace)); |
89 } | 89 } |
90 | 90 |
91 exitCode = error.innerError is IOException | 91 exitCode = error.innerError is IOException |
92 ? exit_codes.io | 92 ? exit_codes.io |
93 : exit_codes.data; | 93 : exit_codes.data; |
94 } else { | 94 } else { |
95 stderr.writeln(getErrorMessage(error)); | 95 stderr.writeln(getErrorMessage(error)); |
96 stderr.writeln(new Trace.from(stackTrace).terse); | 96 stderr.writeln(new Trace.from(stackTrace).terse); |
(...skipping 25 matching lines...) Expand all Loading... |
122 output = stderr; | 122 output = stderr; |
123 } | 123 } |
124 | 124 |
125 output.write("""$message | 125 output.write("""$message |
126 | 126 |
127 Usage: pub run unittest:unittest [files or directories...] | 127 Usage: pub run unittest:unittest [files or directories...] |
128 | 128 |
129 ${_parser.usage} | 129 ${_parser.usage} |
130 """); | 130 """); |
131 } | 131 } |
OLD | NEW |