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

Side by Side Diff: lib/src/runner/reporter/no_io_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
« no previous file with comments | « lib/src/runner/reporter/compact.dart ('k') | lib/src/runner/test_platform.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
kevmoo 2015/03/05 23:14:29 Any way to share code with compact.dart? Seems li
nweiz 2015/03/06 01:40:02 I tried having inheritance here, but there are eno
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.no_io_compact; 5 library unittest.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';
11 import '../../backend/suite.dart'; 11 import '../../backend/suite.dart';
(...skipping 20 matching lines...) Expand all
32 /// or not outputting to a terminal. 32 /// or not outputting to a terminal.
33 final String _red; 33 final String _red;
34 34
35 /// The terminal escape for removing test coloring, or the empty string if 35 /// The terminal escape for removing test coloring, or the empty string if
36 /// this is Windows or not outputting to a terminal. 36 /// this is Windows or not outputting to a terminal.
37 final String _noColor; 37 final String _noColor;
38 38
39 /// The engine used to run the tests. 39 /// The engine used to run the tests.
40 final Engine _engine; 40 final Engine _engine;
41 41
42 /// Whether multiple test suites are being run. 42 /// Whether multiple test files are being run.
43 final bool _multipleSuites; 43 final bool _multiplePaths;
44
45 /// Whether tests are being run on multiple platforms.
46 final bool _multiplePlatforms;
44 47
45 /// A stopwatch that tracks the duration of the full run. 48 /// A stopwatch that tracks the duration of the full run.
46 final _stopwatch = new Stopwatch(); 49 final _stopwatch = new Stopwatch();
47 50
48 /// The set of tests that have completed and been marked as passing. 51 /// The set of tests that have completed and been marked as passing.
49 final _passed = new Set<LiveTest>(); 52 final _passed = new Set<LiveTest>();
50 53
51 /// The set of tests that have completed and been marked as failing or error. 54 /// The set of tests that have completed and been marked as failing or error.
52 final _failed = new Set<LiveTest>(); 55 final _failed = new Set<LiveTest>();
53 56
54 /// The size of [_passed] last time a progress notification was printed. 57 /// The size of [_passed] last time a progress notification was printed.
55 int _lastProgressPassed; 58 int _lastProgressPassed;
56 59
57 /// The size of [_failed] last time a progress notification was printed. 60 /// The size of [_failed] last time a progress notification was printed.
58 int _lastProgressFailed; 61 int _lastProgressFailed;
59 62
60 /// The message printed for the last progress notification. 63 /// The message printed for the last progress notification.
61 String _lastProgressMessage; 64 String _lastProgressMessage;
62 65
63 /// Creates a [NoIoCompactReporter] that will run all tests in [suites]. 66 /// Creates a [NoIoCompactReporter] that will run all tests in [suites].
64 /// 67 ///
65 /// If [color] is `true`, this will use terminal colors; if it's `false`, it 68 /// If [color] is `true`, this will use terminal colors; if it's `false`, it
66 /// won't. 69 /// won't.
67 NoIoCompactReporter(Iterable<Suite> suites, {bool color: true}) 70 NoIoCompactReporter(Iterable<Suite> suites, {bool color: true})
68 : _multipleSuites = suites.length > 1, 71 : _multiplePaths = suites.map((suite) => suite.path).toSet().length > 1,
72 _multiplePlatforms =
73 suites.map((suite) => suite.platform).toSet().length > 1,
69 _engine = new Engine(suites), 74 _engine = new Engine(suites),
70 _green = color ? '\u001b[32m' : '', 75 _green = color ? '\u001b[32m' : '',
71 _red = color ? '\u001b[31m' : '', 76 _red = color ? '\u001b[31m' : '',
72 _noColor = color ? '\u001b[0m' : '' { 77 _noColor = color ? '\u001b[0m' : '' {
73 _engine.onTestStarted.listen((liveTest) { 78 _engine.onTestStarted.listen((liveTest) {
74 liveTest.onStateChange.listen((state) { 79 liveTest.onStateChange.listen((state) {
75 if (state.status != Status.complete) return; 80 if (state.status != Status.complete) return;
76 if (state.result == Result.success) { 81 if (state.result == Result.success) {
77 _passed.add(liveTest); 82 _passed.add(liveTest);
78 } else { 83 } else {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 String _timeString(Duration duration) { 182 String _timeString(Duration duration) {
178 return "${duration.inMinutes.toString().padLeft(2, '0')}:" 183 return "${duration.inMinutes.toString().padLeft(2, '0')}:"
179 "${(duration.inSeconds % 60).toString().padLeft(2, '0')}"; 184 "${(duration.inSeconds % 60).toString().padLeft(2, '0')}";
180 } 185 }
181 186
182 /// Returns a description of [liveTest]. 187 /// Returns a description of [liveTest].
183 /// 188 ///
184 /// This differs from the test's own description in that it may also include 189 /// This differs from the test's own description in that it may also include
185 /// the suite's name. 190 /// the suite's name.
186 String _description(LiveTest liveTest) { 191 String _description(LiveTest liveTest) {
187 if (_multipleSuites) return "${liveTest.suite.name}: ${liveTest.test.name}"; 192 var name = liveTest.test.name;
188 return liveTest.test.name; 193
194 if (_multiplePaths && liveTest.suite.path != null) {
195 name = "${liveTest.suite.path}: $name";
196 }
197
198 if (_multiplePlatforms && liveTest.suite.platform != null) {
199 name = "[$liveTest.suite.platform] $name";
200 }
201
202 return name;
189 } 203 }
190 } 204 }
OLDNEW
« no previous file with comments | « lib/src/runner/reporter/compact.dart ('k') | lib/src/runner/test_platform.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698