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 test.runner.reporter.compact; | 5 library test.runner.reporter.compact; |
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 24 matching lines...) Loading... |
35 final String _red; | 35 final String _red; |
36 | 36 |
37 /// The terminal escape for yellow text, or the empty string if this is | 37 /// The terminal escape for yellow text, or the empty string if this is |
38 /// Windows or not outputting to a terminal. | 38 /// Windows or not outputting to a terminal. |
39 final String _yellow; | 39 final String _yellow; |
40 | 40 |
41 /// The terminal escape for removing test coloring, or the empty string if | 41 /// The terminal escape for removing test coloring, or the empty string if |
42 /// this is Windows or not outputting to a terminal. | 42 /// this is Windows or not outputting to a terminal. |
43 final String _noColor; | 43 final String _noColor; |
44 | 44 |
| 45 /// Whether to use verbose stack traces. |
| 46 final bool _verboseTrace; |
| 47 |
45 /// The engine used to run the tests. | 48 /// The engine used to run the tests. |
46 final Engine _engine; | 49 final Engine _engine; |
47 | 50 |
48 /// Whether multiple test files are being run. | 51 /// Whether multiple test files are being run. |
49 final bool _multiplePaths; | 52 final bool _multiplePaths; |
50 | 53 |
51 /// Whether tests are being run on multiple platforms. | 54 /// Whether tests are being run on multiple platforms. |
52 final bool _multiplePlatforms; | 55 final bool _multiplePlatforms; |
53 | 56 |
54 /// A stopwatch that tracks the duration of the full run. | 57 /// A stopwatch that tracks the duration of the full run. |
(...skipping 25 matching lines...) Loading... |
80 | 83 |
81 /// The message printed for the last progress notification. | 84 /// The message printed for the last progress notification. |
82 String _lastProgressMessage; | 85 String _lastProgressMessage; |
83 | 86 |
84 // Whether a newline has been printed since the last progress line. | 87 // Whether a newline has been printed since the last progress line. |
85 var _printedNewline = true; | 88 var _printedNewline = true; |
86 | 89 |
87 /// Creates a [ConsoleReporter] that will run all tests in [suites]. | 90 /// Creates a [ConsoleReporter] that will run all tests in [suites]. |
88 /// | 91 /// |
89 /// [concurrency] controls how many suites are run at once. If [color] is | 92 /// [concurrency] controls how many suites are run at once. If [color] is |
90 /// `true`, this will use terminal colors; if it's `false`, it won't. | 93 /// `true`, this will use terminal colors; if it's `false`, it won't. If |
91 CompactReporter(Iterable<Suite> suites, {int concurrency, bool color: true}) | 94 /// [verboseTrace] is `true`, this will print core library frames. |
| 95 CompactReporter(Iterable<Suite> suites, {int concurrency, bool color: true, |
| 96 bool verboseTrace: false}) |
92 : _multiplePaths = suites.map((suite) => suite.path).toSet().length > 1, | 97 : _multiplePaths = suites.map((suite) => suite.path).toSet().length > 1, |
93 _multiplePlatforms = | 98 _multiplePlatforms = |
94 suites.map((suite) => suite.platform).toSet().length > 1, | 99 suites.map((suite) => suite.platform).toSet().length > 1, |
95 _engine = new Engine(suites, concurrency: concurrency), | 100 _engine = new Engine(suites, concurrency: concurrency), |
| 101 _verboseTrace = verboseTrace, |
96 _color = color, | 102 _color = color, |
97 _green = color ? '\u001b[32m' : '', | 103 _green = color ? '\u001b[32m' : '', |
98 _red = color ? '\u001b[31m' : '', | 104 _red = color ? '\u001b[31m' : '', |
99 _yellow = color ? '\u001b[33m' : '', | 105 _yellow = color ? '\u001b[33m' : '', |
100 _noColor = color ? '\u001b[0m' : '' { | 106 _noColor = color ? '\u001b[0m' : '' { |
101 _engine.onTestStarted.listen((liveTest) { | 107 _engine.onTestStarted.listen((liveTest) { |
102 if (_active.isEmpty) _progressLine(_description(liveTest)); | 108 if (_active.isEmpty) _progressLine(_description(liveTest)); |
103 _active.add(liveTest); | 109 _active.add(liveTest); |
104 _printedNewline = false; | 110 _printedNewline = false; |
105 | 111 |
(...skipping 31 matching lines...) Loading... |
137 | 143 |
138 liveTest.onError.listen((error) { | 144 liveTest.onError.listen((error) { |
139 if (liveTest.state.status != Status.complete) return; | 145 if (liveTest.state.status != Status.complete) return; |
140 | 146 |
141 _progressLine(_description(liveTest)); | 147 _progressLine(_description(liveTest)); |
142 if (!_printedNewline) print(''); | 148 if (!_printedNewline) print(''); |
143 _printedNewline = true; | 149 _printedNewline = true; |
144 | 150 |
145 if (error.error is! LoadException) { | 151 if (error.error is! LoadException) { |
146 print(indent(error.error.toString())); | 152 print(indent(error.error.toString())); |
147 print(indent(terseChain(error.stackTrace).toString())); | 153 var chain = terseChain(error.stackTrace, verbose: _verboseTrace); |
| 154 print(indent(chain.toString())); |
148 return; | 155 return; |
149 } | 156 } |
150 | 157 |
151 print(indent(error.error.toString(color: _color))); | 158 print(indent(error.error.toString(color: _color))); |
152 | 159 |
153 // Only print stack traces for load errors that come from the user's cod
e. | 160 // Only print stack traces for load errors that come from the user's cod
e. |
154 if (error.error.innerError is! IOException && | 161 if (error.error.innerError is! IOException && |
155 error.error.innerError is! IsolateSpawnException && | 162 error.error.innerError is! IsolateSpawnException && |
156 error.error.innerError is! FormatException && | 163 error.error.innerError is! FormatException && |
157 error.error.innerError is! String) { | 164 error.error.innerError is! String) { |
(...skipping 134 matching lines...) Loading... |
292 name = "${liveTest.suite.path}: $name"; | 299 name = "${liveTest.suite.path}: $name"; |
293 } | 300 } |
294 | 301 |
295 if (_multiplePlatforms && liveTest.suite.platform != null) { | 302 if (_multiplePlatforms && liveTest.suite.platform != null) { |
296 name = "[${liveTest.suite.platform}] $name"; | 303 name = "[${liveTest.suite.platform}] $name"; |
297 } | 304 } |
298 | 305 |
299 return name; | 306 return name; |
300 } | 307 } |
301 } | 308 } |
OLD | NEW |