Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: lib/src/runner/reporter/compact.dart

Issue 983573002: Add support for running browser tests to the test runner. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 unittest.runner.reporter.compact; 5 library unittest.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 18 matching lines...) Expand all
29 /// or not outputting to a terminal. 29 /// or not outputting to a terminal.
30 final String _red; 30 final String _red;
31 31
32 /// The terminal escape for removing test coloring, or the empty string if 32 /// The terminal escape for removing test coloring, or the empty string if
33 /// this is Windows or not outputting to a terminal. 33 /// this is Windows or not outputting to a terminal.
34 final String _noColor; 34 final String _noColor;
35 35
36 /// The engine used to run the tests. 36 /// The engine used to run the tests.
37 final Engine _engine; 37 final Engine _engine;
38 38
39 /// Whether multiple test suites are being run. 39 /// Whether multiple test files are being run.
40 final bool _multipleSuites; 40 final bool _multiplePaths;
41
42 /// Whether tests are being run on multiple platforms.
43 final bool _multiplePlatforms;
41 44
42 /// A stopwatch that tracks the duration of the full run. 45 /// A stopwatch that tracks the duration of the full run.
43 final _stopwatch = new Stopwatch(); 46 final _stopwatch = new Stopwatch();
44 47
45 /// 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.
46 final _passed = new Set<LiveTest>(); 49 final _passed = new Set<LiveTest>();
47 50
48 /// 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.
49 final _failed = new Set<LiveTest>(); 52 final _failed = new Set<LiveTest>();
50 53
51 /// The size of [_passed] last time a progress notification was printed. 54 /// The size of [_passed] last time a progress notification was printed.
52 int _lastProgressPassed; 55 int _lastProgressPassed;
53 56
54 /// The size of [_failed] last time a progress notification was printed. 57 /// The size of [_failed] last time a progress notification was printed.
55 int _lastProgressFailed; 58 int _lastProgressFailed;
56 59
57 /// The message printed for the last progress notification. 60 /// The message printed for the last progress notification.
58 String _lastProgressMessage; 61 String _lastProgressMessage;
59 62
60 /// Creates a [ConsoleReporter] that will run all tests in [suites]. 63 /// Creates a [ConsoleReporter] that will run all tests in [suites].
61 /// 64 ///
62 /// If [color] is `true`, this will use terminal colors; if it's `false`, it 65 /// If [color] is `true`, this will use terminal colors; if it's `false`, it
63 /// won't. 66 /// won't.
64 CompactReporter(Iterable<Suite> suites, {bool color: true}) 67 CompactReporter(Iterable<Suite> suites, {bool color: true})
65 : _multipleSuites = suites.length > 1, 68 : _multiplePaths = suites.map((suite) => suite.path).toSet().length > 1,
69 _multiplePlatforms =
70 suites.map((suite) => suite.platform).toSet().length > 1,
66 _engine = new Engine(suites), 71 _engine = new Engine(suites),
67 _green = color ? '\u001b[32m' : '', 72 _green = color ? '\u001b[32m' : '',
68 _red = color ? '\u001b[31m' : '', 73 _red = color ? '\u001b[31m' : '',
69 _noColor = color ? '\u001b[0m' : '' { 74 _noColor = color ? '\u001b[0m' : '' {
70 _engine.onTestStarted.listen((liveTest) { 75 _engine.onTestStarted.listen((liveTest) {
71 _progressLine(_description(liveTest)); 76 _progressLine(_description(liveTest));
72 liveTest.onStateChange.listen((state) { 77 liveTest.onStateChange.listen((state) {
73 if (state.status != Status.complete) return; 78 if (state.status != Status.complete) return;
74 if (state.result == Result.success) { 79 if (state.result == Result.success) {
75 _passed.add(liveTest); 80 _passed.add(liveTest);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 String _timeString(Duration duration) { 186 String _timeString(Duration duration) {
182 return "${duration.inMinutes.toString().padLeft(2, '0')}:" 187 return "${duration.inMinutes.toString().padLeft(2, '0')}:"
183 "${(duration.inSeconds % 60).toString().padLeft(2, '0')}"; 188 "${(duration.inSeconds % 60).toString().padLeft(2, '0')}";
184 } 189 }
185 190
186 /// Returns a description of [liveTest]. 191 /// Returns a description of [liveTest].
187 /// 192 ///
188 /// This differs from the test's own description in that it may also include 193 /// This differs from the test's own description in that it may also include
189 /// the suite's name. 194 /// the suite's name.
190 String _description(LiveTest liveTest) { 195 String _description(LiveTest liveTest) {
191 if (_multipleSuites) return "${liveTest.suite.name}: ${liveTest.test.name}"; 196 var name = liveTest.test.name;
192 return liveTest.test.name; 197
198 if (_multiplePaths && liveTest.suite.path != null) {
199 name = "${liveTest.suite.path}: $name";
200 }
201
202 if (_multiplePlatforms && liveTest.suite.platform != null) {
203 name = "[${liveTest.suite.platform}] $name";
204 }
205
206 return name;
193 } 207 }
194 } 208 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698