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

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

Issue 1641353002: Expand the JSON reporter to enable a progress bar. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 4 years, 10 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:convert'; 6 import 'dart:convert';
7 7
8 import '../../backend/group.dart'; 8 import '../../backend/group.dart';
9 import '../../backend/live_test.dart'; 9 import '../../backend/live_test.dart';
10 import '../../backend/metadata.dart'; 10 import '../../backend/metadata.dart';
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 } 59 }
60 60
61 JsonReporter._(this._engine, {bool verboseTrace: false}) 61 JsonReporter._(this._engine, {bool verboseTrace: false})
62 : _verboseTrace = verboseTrace { 62 : _verboseTrace = verboseTrace {
63 _subscriptions.add(_engine.onTestStarted.listen(_onTestStarted)); 63 _subscriptions.add(_engine.onTestStarted.listen(_onTestStarted));
64 64
65 /// Convert the future to a stream so that the subscription can be paused or 65 /// Convert the future to a stream so that the subscription can be paused or
66 /// canceled. 66 /// canceled.
67 _subscriptions.add(_engine.success.asStream().listen(_onDone)); 67 _subscriptions.add(_engine.success.asStream().listen(_onDone));
68 68
69 _subscriptions.add(_engine.onSuiteAdded.listen(null, onDone: () {
70 _emit("allSuites", {
71 "count": _engine.addedSuites.length
72 });
73 }));
74
69 _emit("start", { 75 _emit("start", {
70 "protocolVersion": "0.1.0", 76 "protocolVersion": "0.1.0",
71 "runnerVersion": testVersion 77 "runnerVersion": testVersion
72 }); 78 });
73 } 79 }
74 80
75 void pause() { 81 void pause() {
76 if (_paused) return; 82 if (_paused) return;
77 _paused = true; 83 _paused = true;
78 84
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 193
188 var id = _nextID++; 194 var id = _nextID++;
189 _groupIDs[group] = id; 195 _groupIDs[group] = id;
190 196
191 _emit("group", { 197 _emit("group", {
192 "group": { 198 "group": {
193 "id": id, 199 "id": id,
194 "suiteID": suiteID, 200 "suiteID": suiteID,
195 "parentID": parentID, 201 "parentID": parentID,
196 "name": group.name, 202 "name": group.name,
197 "metadata": _serializeMetadata(group.metadata) 203 "metadata": _serializeMetadata(group.metadata),
204 "testCount": group.testCount
198 } 205 }
199 }); 206 });
200 parentID = id; 207 parentID = id;
201 return id; 208 return id;
202 }).toList(); 209 }).toList();
203 } 210 }
204 211
205 /// Serializes [metadata] into a JSON-protocol-compatible map. 212 /// Serializes [metadata] into a JSON-protocol-compatible map.
206 Map _serializeMetadata(Metadata metadata) => 213 Map _serializeMetadata(Metadata metadata) =>
207 {"skip": metadata.skip, "skipReason": metadata.skipReason}; 214 {"skip": metadata.skip, "skipReason": metadata.skipReason};
(...skipping 28 matching lines...) Expand all
236 _emit("done", {"success": success}); 243 _emit("done", {"success": success});
237 } 244 }
238 245
239 /// Emits an event with the given type and attributes. 246 /// Emits an event with the given type and attributes.
240 void _emit(String type, Map attributes) { 247 void _emit(String type, Map attributes) {
241 attributes["type"] = type; 248 attributes["type"] = type;
242 attributes["time"] = _stopwatch.elapsed.inMilliseconds; 249 attributes["time"] = _stopwatch.elapsed.inMilliseconds;
243 print(JSON.encode(attributes)); 250 print(JSON.encode(attributes));
244 } 251 }
245 } 252 }
OLDNEW
« json_reporter.md ('K') | « lib/src/runner/engine.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698