| 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:io'; | 6 import 'dart:io'; |
| 7 import 'dart:isolate'; | 7 import 'dart:isolate'; |
| 8 | 8 |
| 9 import '../../backend/live_test.dart'; | 9 import '../../backend/live_test.dart'; |
| 10 import '../../backend/message.dart'; |
| 10 import '../../backend/state.dart'; | 11 import '../../backend/state.dart'; |
| 11 import '../../utils.dart'; | 12 import '../../utils.dart'; |
| 12 import '../../utils.dart' as utils; | 13 import '../../utils.dart' as utils; |
| 13 import '../engine.dart'; | 14 import '../engine.dart'; |
| 14 import '../load_exception.dart'; | 15 import '../load_exception.dart'; |
| 15 import '../load_suite.dart'; | 16 import '../load_suite.dart'; |
| 16 import '../reporter.dart'; | 17 import '../reporter.dart'; |
| 17 | 18 |
| 18 /// The maximum console line length. | 19 /// The maximum console line length. |
| 19 /// | 20 /// |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 if (_engine.active.length == 1 && _engine.active.first == liveTest) { | 193 if (_engine.active.length == 1 && _engine.active.first == liveTest) { |
| 193 _progressLine(_description(liveTest)); | 194 _progressLine(_description(liveTest)); |
| 194 } | 195 } |
| 195 | 196 |
| 196 _subscriptions.add(liveTest.onStateChange | 197 _subscriptions.add(liveTest.onStateChange |
| 197 .listen((state) => _onStateChange(liveTest, state))); | 198 .listen((state) => _onStateChange(liveTest, state))); |
| 198 | 199 |
| 199 _subscriptions.add(liveTest.onError.listen((error) => | 200 _subscriptions.add(liveTest.onError.listen((error) => |
| 200 _onError(liveTest, error.error, error.stackTrace))); | 201 _onError(liveTest, error.error, error.stackTrace))); |
| 201 | 202 |
| 202 _subscriptions.add(liveTest.onPrint.listen((line) { | 203 _subscriptions.add(liveTest.onMessage.listen((message) { |
| 203 _progressLine(_description(liveTest), truncate: false); | 204 _progressLine(_description(liveTest), truncate: false); |
| 204 if (!_printedNewline) print(''); | 205 if (!_printedNewline) print(''); |
| 205 _printedNewline = true; | 206 _printedNewline = true; |
| 206 | 207 |
| 207 print(line); | 208 var text = message.text; |
| 209 if (message.type == MessageType.skip) text = ' $_yellow$text$_noColor'; |
| 210 print(text); |
| 208 })); | 211 })); |
| 209 } | 212 } |
| 210 | 213 |
| 211 /// A callback called when [liveTest]'s state becomes [state]. | 214 /// A callback called when [liveTest]'s state becomes [state]. |
| 212 void _onStateChange(LiveTest liveTest, State state) { | 215 void _onStateChange(LiveTest liveTest, State state) { |
| 213 if (state.status != Status.complete) return; | 216 if (state.status != Status.complete) return; |
| 214 | 217 |
| 215 if (state.result == Result.skipped && | 218 // Always display the name of the oldest active test, unless testing |
| 216 liveTest.test.metadata.skipReason != null) { | 219 // is finished in which case display the last test to complete. |
| 220 if (_engine.active.isEmpty) { |
| 217 _progressLine(_description(liveTest)); | 221 _progressLine(_description(liveTest)); |
| 218 print(''); | |
| 219 print(indent('${_yellow}Skip: ${liveTest.test.metadata.skipReason}' | |
| 220 '$_noColor')); | |
| 221 } else { | 222 } else { |
| 222 // Always display the name of the oldest active test, unless testing | 223 _progressLine(_description(_engine.active.first)); |
| 223 // is finished in which case display the last test to complete. | |
| 224 if (_engine.active.isEmpty) { | |
| 225 _progressLine(_description(liveTest)); | |
| 226 } else { | |
| 227 _progressLine(_description(_engine.active.first)); | |
| 228 } | |
| 229 } | 224 } |
| 230 } | 225 } |
| 231 | 226 |
| 232 /// A callback called when [liveTest] throws [error]. | 227 /// A callback called when [liveTest] throws [error]. |
| 233 void _onError(LiveTest liveTest, error, StackTrace stackTrace) { | 228 void _onError(LiveTest liveTest, error, StackTrace stackTrace) { |
| 234 if (liveTest.state.status != Status.complete) return; | 229 if (liveTest.state.status != Status.complete) return; |
| 235 | 230 |
| 236 _progressLine(_description(liveTest), truncate: false); | 231 _progressLine(_description(liveTest), truncate: false); |
| 237 if (!_printedNewline) print(''); | 232 if (!_printedNewline) print(''); |
| 238 _printedNewline = true; | 233 _printedNewline = true; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 | 382 |
| 388 if (_printPlatform && liveTest.suite.platform != null) { | 383 if (_printPlatform && liveTest.suite.platform != null) { |
| 389 name = "[${liveTest.suite.platform.name}] $name"; | 384 name = "[${liveTest.suite.platform.name}] $name"; |
| 390 } | 385 } |
| 391 | 386 |
| 392 if (liveTest.suite is LoadSuite) name = "$_bold$_gray$name$_noColor"; | 387 if (liveTest.suite is LoadSuite) name = "$_bold$_gray$name$_noColor"; |
| 393 | 388 |
| 394 return name; | 389 return name; |
| 395 } | 390 } |
| 396 } | 391 } |
| OLD | NEW |