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 | 9 |
10 import '../../backend/live_test.dart'; | 10 import '../../backend/live_test.dart'; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 /// A stopwatch that tracks the duration of the full run. | 45 /// A stopwatch that tracks the duration of the full run. |
46 final _stopwatch = new Stopwatch(); | 46 final _stopwatch = new Stopwatch(); |
47 | 47 |
48 /// The set of tests that have completed and been marked as passing. | 48 /// The set of tests that have completed and been marked as passing. |
49 final _passed = new Set<LiveTest>(); | 49 final _passed = new Set<LiveTest>(); |
50 | 50 |
51 /// The set of tests that have completed and been marked as failing or error. | 51 /// The set of tests that have completed and been marked as failing or error. |
52 final _failed = new Set<LiveTest>(); | 52 final _failed = new Set<LiveTest>(); |
53 | 53 |
| 54 /// The set of tests that are still running. |
| 55 final _active = new List<LiveTest>(); |
| 56 |
54 /// Whether [close] has been called. | 57 /// Whether [close] has been called. |
55 bool _closed = false; | 58 bool _closed = false; |
56 | 59 |
57 /// The size of [_passed] last time a progress notification was printed. | 60 /// The size of [_passed] last time a progress notification was printed. |
58 int _lastProgressPassed; | 61 int _lastProgressPassed; |
59 | 62 |
60 /// The size of [_failed] last time a progress notification was printed. | 63 /// The size of [_failed] last time a progress notification was printed. |
61 int _lastProgressFailed; | 64 int _lastProgressFailed; |
62 | 65 |
63 /// The message printed for the last progress notification. | 66 /// The message printed for the last progress notification. |
64 String _lastProgressMessage; | 67 String _lastProgressMessage; |
65 | 68 |
66 // Whether a newline has been printed since the last progress line. | 69 // Whether a newline has been printed since the last progress line. |
67 var _printedNewline = true; | 70 var _printedNewline = true; |
68 | 71 |
69 /// Creates a [ConsoleReporter] that will run all tests in [suites]. | 72 /// Creates a [ConsoleReporter] that will run all tests in [suites]. |
70 /// | 73 /// |
71 /// If [color] is `true`, this will use terminal colors; if it's `false`, it | 74 /// If [color] is `true`, this will use terminal colors; if it's `false`, it |
72 /// won't. | 75 /// won't. |
73 CompactReporter(Iterable<Suite> suites, {bool color: true}) | 76 CompactReporter(Iterable<Suite> suites, {int concurrency, bool color: true}) |
74 : _multiplePaths = suites.map((suite) => suite.path).toSet().length > 1, | 77 : _multiplePaths = suites.map((suite) => suite.path).toSet().length > 1, |
75 _multiplePlatforms = | 78 _multiplePlatforms = |
76 suites.map((suite) => suite.platform).toSet().length > 1, | 79 suites.map((suite) => suite.platform).toSet().length > 1, |
77 _engine = new Engine(suites), | 80 _engine = new Engine(suites, concurrency: concurrency), |
78 _green = color ? '\u001b[32m' : '', | 81 _green = color ? '\u001b[32m' : '', |
79 _red = color ? '\u001b[31m' : '', | 82 _red = color ? '\u001b[31m' : '', |
80 _noColor = color ? '\u001b[0m' : '' { | 83 _noColor = color ? '\u001b[0m' : '' { |
81 _engine.onTestStarted.listen((liveTest) { | 84 _engine.onTestStarted.listen((liveTest) { |
82 _progressLine(_description(liveTest)); | 85 if (_active.isEmpty) _progressLine(_description(liveTest)); |
| 86 _active.add(liveTest); |
83 _printedNewline = false; | 87 _printedNewline = false; |
84 | 88 |
85 liveTest.onStateChange.listen((state) { | 89 liveTest.onStateChange.listen((state) { |
86 if (state.status != Status.complete) return; | 90 if (state.status != Status.complete) return; |
| 91 _active.remove(liveTest); |
87 if (state.result == Result.success) { | 92 if (state.result == Result.success) { |
88 _passed.add(liveTest); | 93 _passed.add(liveTest); |
89 } else { | 94 } else { |
90 _passed.remove(liveTest); | 95 _passed.remove(liveTest); |
91 _failed.add(liveTest); | 96 _failed.add(liveTest); |
92 } | 97 } |
93 _progressLine(_description(liveTest)); | 98 |
| 99 // Always display the name of the oldest active test, unless testing is |
| 100 // finished in which case display the last test to complete. |
| 101 if (_active.isEmpty) { |
| 102 _progressLine(_description(liveTest)); |
| 103 } else { |
| 104 _progressLine(_description(_active.first)); |
| 105 } |
| 106 |
94 _printedNewline = false; | 107 _printedNewline = false; |
95 }); | 108 }); |
96 | 109 |
97 liveTest.onError.listen((error) { | 110 liveTest.onError.listen((error) { |
98 if (liveTest.state.status != Status.complete) return; | 111 if (liveTest.state.status != Status.complete) return; |
99 | 112 |
100 _progressLine(_description(liveTest)); | 113 _progressLine(_description(liveTest)); |
101 if (!_printedNewline) print(''); | 114 if (!_printedNewline) print(''); |
102 _printedNewline = true; | 115 _printedNewline = true; |
103 | 116 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 name = "${liveTest.suite.path}: $name"; | 239 name = "${liveTest.suite.path}: $name"; |
227 } | 240 } |
228 | 241 |
229 if (_multiplePlatforms && liveTest.suite.platform != null) { | 242 if (_multiplePlatforms && liveTest.suite.platform != null) { |
230 name = "[${liveTest.suite.platform}] $name"; | 243 name = "[${liveTest.suite.platform}] $name"; |
231 } | 244 } |
232 | 245 |
233 return name; | 246 return name; |
234 } | 247 } |
235 } | 248 } |
OLD | NEW |