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.no_io_compact; | 5 library test.runner.reporter.no_io_compact; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import '../../backend/live_test.dart'; | 9 import '../../backend/live_test.dart'; |
10 import '../../backend/state.dart'; | 10 import '../../backend/state.dart'; |
(...skipping 22 matching lines...) Expand all Loading... |
33 final String _red; | 33 final String _red; |
34 | 34 |
35 /// The terminal escape for yellow text, or the empty string if this is | 35 /// The terminal escape for yellow text, or the empty string if this is |
36 /// Windows or not outputting to a terminal. | 36 /// Windows or not outputting to a terminal. |
37 final String _yellow; | 37 final String _yellow; |
38 | 38 |
39 /// The terminal escape for removing test coloring, or the empty string if | 39 /// The terminal escape for removing test coloring, or the empty string if |
40 /// this is Windows or not outputting to a terminal. | 40 /// this is Windows or not outputting to a terminal. |
41 final String _noColor; | 41 final String _noColor; |
42 | 42 |
| 43 /// Whether to use verbose stack traces. |
| 44 final bool _verboseTrace; |
| 45 |
43 /// The engine used to run the tests. | 46 /// The engine used to run the tests. |
44 final Engine _engine; | 47 final Engine _engine; |
45 | 48 |
46 /// Whether multiple test files are being run. | 49 /// Whether multiple test files are being run. |
47 final bool _multiplePaths; | 50 final bool _multiplePaths; |
48 | 51 |
49 /// Whether tests are being run on multiple platforms. | 52 /// Whether tests are being run on multiple platforms. |
50 final bool _multiplePlatforms; | 53 final bool _multiplePlatforms; |
51 | 54 |
52 /// A stopwatch that tracks the duration of the full run. | 55 /// A stopwatch that tracks the duration of the full run. |
(...skipping 19 matching lines...) Expand all Loading... |
72 | 75 |
73 /// The size of [_failed] last time a progress notification was printed. | 76 /// The size of [_failed] last time a progress notification was printed. |
74 int _lastProgressFailed; | 77 int _lastProgressFailed; |
75 | 78 |
76 /// The message printed for the last progress notification. | 79 /// The message printed for the last progress notification. |
77 String _lastProgressMessage; | 80 String _lastProgressMessage; |
78 | 81 |
79 /// Creates a [NoIoCompactReporter] that will run all tests in [suites]. | 82 /// Creates a [NoIoCompactReporter] that will run all tests in [suites]. |
80 /// | 83 /// |
81 /// [concurrency] controls how many suites are run at once. If [color] is | 84 /// [concurrency] controls how many suites are run at once. If [color] is |
82 /// `true`, this will use terminal colors; if it's `false`, it won't. | 85 /// `true`, this will use terminal colors; if it's `false`, it won't. If |
83 ExpandedReporter(Iterable<Suite> suites, {int concurrency, bool color: true}) | 86 /// [verboseTrace] is `true`, this will print core library frames. |
| 87 ExpandedReporter(Iterable<Suite> suites, {int concurrency, bool color: true, |
| 88 bool verboseTrace: false}) |
84 : _multiplePaths = suites.map((suite) => suite.path).toSet().length > 1, | 89 : _multiplePaths = suites.map((suite) => suite.path).toSet().length > 1, |
85 _multiplePlatforms = | 90 _multiplePlatforms = |
86 suites.map((suite) => suite.platform).toSet().length > 1, | 91 suites.map((suite) => suite.platform).toSet().length > 1, |
87 _engine = new Engine(suites, concurrency: concurrency), | 92 _engine = new Engine(suites, concurrency: concurrency), |
| 93 _verboseTrace = verboseTrace, |
88 _green = color ? '\u001b[32m' : '', | 94 _green = color ? '\u001b[32m' : '', |
89 _red = color ? '\u001b[31m' : '', | 95 _red = color ? '\u001b[31m' : '', |
90 _yellow = color ? '\u001b[33m' : '', | 96 _yellow = color ? '\u001b[33m' : '', |
91 _noColor = color ? '\u001b[0m' : '' { | 97 _noColor = color ? '\u001b[0m' : '' { |
92 _engine.onTestStarted.listen((liveTest) { | 98 _engine.onTestStarted.listen((liveTest) { |
93 if (_active.isEmpty) _progressLine(_description(liveTest)); | 99 if (_active.isEmpty) _progressLine(_description(liveTest)); |
94 _active.add(liveTest); | 100 _active.add(liveTest); |
95 | 101 |
96 liveTest.onStateChange.listen((state) { | 102 liveTest.onStateChange.listen((state) { |
97 if (state.status != Status.complete) return; | 103 if (state.status != Status.complete) return; |
(...skipping 18 matching lines...) Expand all Loading... |
116 // test. | 122 // test. |
117 _progressLine(_description(_active.first)); | 123 _progressLine(_description(_active.first)); |
118 } | 124 } |
119 }); | 125 }); |
120 | 126 |
121 liveTest.onError.listen((error) { | 127 liveTest.onError.listen((error) { |
122 if (liveTest.state.status != Status.complete) return; | 128 if (liveTest.state.status != Status.complete) return; |
123 | 129 |
124 _progressLine(_description(liveTest)); | 130 _progressLine(_description(liveTest)); |
125 print(indent(error.error.toString())); | 131 print(indent(error.error.toString())); |
126 print(indent(terseChain(error.stackTrace).toString())); | 132 var chain = terseChain(error.stackTrace, verbose: _verboseTrace); |
| 133 print(indent(chain.toString())); |
127 }); | 134 }); |
128 | 135 |
129 liveTest.onPrint.listen((line) { | 136 liveTest.onPrint.listen((line) { |
130 _progressLine(_description(liveTest)); | 137 _progressLine(_description(liveTest)); |
131 print(line); | 138 print(line); |
132 }); | 139 }); |
133 }); | 140 }); |
134 } | 141 } |
135 | 142 |
136 /// Runs all tests in all provided suites. | 143 /// Runs all tests in all provided suites. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 name = "${liveTest.suite.path}: $name"; | 249 name = "${liveTest.suite.path}: $name"; |
243 } | 250 } |
244 | 251 |
245 if (_multiplePlatforms && liveTest.suite.platform != null) { | 252 if (_multiplePlatforms && liveTest.suite.platform != null) { |
246 name = "[${liveTest.suite.platform}] $name"; | 253 name = "[${liveTest.suite.platform}] $name"; |
247 } | 254 } |
248 | 255 |
249 return name; | 256 return name; |
250 } | 257 } |
251 } | 258 } |
OLD | NEW |