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 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:isolate'; | 6 import 'dart:isolate'; |
7 | 7 |
8 import '../../backend/live_test.dart'; | 8 import '../../backend/live_test.dart'; |
| 9 import '../../backend/message.dart'; |
9 import '../../backend/state.dart'; | 10 import '../../backend/state.dart'; |
10 import '../../utils.dart'; | 11 import '../../utils.dart'; |
11 import '../engine.dart'; | 12 import '../engine.dart'; |
12 import '../load_exception.dart'; | 13 import '../load_exception.dart'; |
13 import '../load_suite.dart'; | 14 import '../load_suite.dart'; |
14 import '../reporter.dart'; | 15 import '../reporter.dart'; |
15 | 16 |
16 /// The maximum console line length. | 17 /// The maximum console line length. |
17 /// | 18 /// |
18 /// Lines longer than this will be cropped. | 19 /// Lines longer than this will be cropped. |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 _engine.active.first == liveTest && | 178 _engine.active.first == liveTest && |
178 liveTest.test.name.startsWith("compiling ")) { | 179 liveTest.test.name.startsWith("compiling ")) { |
179 // Print a progress line for load tests that come from compiling JS, since | 180 // Print a progress line for load tests that come from compiling JS, since |
180 // that takes a long time. | 181 // that takes a long time. |
181 _progressLine(_description(liveTest)); | 182 _progressLine(_description(liveTest)); |
182 } | 183 } |
183 | 184 |
184 _subscriptions.add(liveTest.onError.listen((error) => | 185 _subscriptions.add(liveTest.onError.listen((error) => |
185 _onError(liveTest, error.error, error.stackTrace))); | 186 _onError(liveTest, error.error, error.stackTrace))); |
186 | 187 |
187 _subscriptions.add(liveTest.onPrint.listen((line) { | 188 _subscriptions.add(liveTest.onMessage.listen((message) { |
188 _progressLine(_description(liveTest)); | 189 _progressLine(_description(liveTest)); |
189 print(line); | 190 var text = message.text; |
| 191 if (message.type == MessageType.skip) text = ' $_yellow$text$_noColor'; |
| 192 print(text); |
190 })); | 193 })); |
191 } | 194 } |
192 | 195 |
193 /// A callback called when [liveTest]'s state becomes [state]. | 196 /// A callback called when [liveTest]'s state becomes [state]. |
194 void _onStateChange(LiveTest liveTest, State state) { | 197 void _onStateChange(LiveTest liveTest, State state) { |
195 if (state.status != Status.complete) return; | 198 if (state.status != Status.complete) return; |
196 | 199 |
197 if (state.result == Result.skipped && | 200 // If any tests are running, display the name of the oldest active |
198 liveTest.test.metadata.skipReason != null) { | 201 // test. |
199 print(indent('${_yellow}Skip: ${liveTest.test.metadata.skipReason}' | 202 if (_engine.active.isNotEmpty) { |
200 '$_noColor')); | |
201 } else if (_engine.active.isNotEmpty) { | |
202 // If any tests are running, display the name of the oldest active | |
203 // test. | |
204 _progressLine(_description(_engine.active.first)); | 203 _progressLine(_description(_engine.active.first)); |
205 } | 204 } |
206 } | 205 } |
207 | 206 |
208 /// A callback called when [liveTest] throws [error]. | 207 /// A callback called when [liveTest] throws [error]. |
209 void _onError(LiveTest liveTest, error, StackTrace stackTrace) { | 208 void _onError(LiveTest liveTest, error, StackTrace stackTrace) { |
210 if (liveTest.state.status != Status.complete) return; | 209 if (liveTest.state.status != Status.complete) return; |
211 | 210 |
212 _progressLine(_description(liveTest)); | 211 _progressLine(_description(liveTest)); |
213 | 212 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 | 320 |
322 if (_printPlatform && liveTest.suite.platform != null) { | 321 if (_printPlatform && liveTest.suite.platform != null) { |
323 name = "[${liveTest.suite.platform.name}] $name"; | 322 name = "[${liveTest.suite.platform.name}] $name"; |
324 } | 323 } |
325 | 324 |
326 if (liveTest.suite is LoadSuite) name = "$_bold$_gray$name$_noColor"; | 325 if (liveTest.suite is LoadSuite) name = "$_bold$_gray$name$_noColor"; |
327 | 326 |
328 return name; | 327 return name; |
329 } | 328 } |
330 } | 329 } |
OLD | NEW |