Chromium Code Reviews

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

Issue 2099503002: Add a dedicated Result for skipped tests. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « lib/src/runner/reporter/expanded.dart ('k') | test/runner/engine_test.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
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/group_entry.dart'; 9 import '../../backend/group_entry.dart';
10 import '../../backend/live_test.dart'; 10 import '../../backend/live_test.dart';
11 import '../../backend/metadata.dart'; 11 import '../../backend/metadata.dart';
12 import '../../backend/state.dart';
12 import '../../backend/suite.dart'; 13 import '../../backend/suite.dart';
13 import '../../backend/test_platform.dart'; 14 import '../../backend/test_platform.dart';
14 import '../../frontend/expect.dart'; 15 import '../../frontend/expect.dart';
15 import '../../utils.dart'; 16 import '../../utils.dart';
16 import '../engine.dart'; 17 import '../engine.dart';
17 import '../load_suite.dart'; 18 import '../load_suite.dart';
18 import '../reporter.dart'; 19 import '../reporter.dart';
19 import '../version.dart'; 20 import '../version.dart';
20 21
21 /// A reporter that prints machine-readable JSON-formatted test results. 22 /// A reporter that prints machine-readable JSON-formatted test results.
(...skipping 199 matching lines...)
221 } 222 }
222 223
223 /// Serializes [metadata] into a JSON-protocol-compatible map. 224 /// Serializes [metadata] into a JSON-protocol-compatible map.
224 Map _serializeMetadata(Metadata metadata) => 225 Map _serializeMetadata(Metadata metadata) =>
225 {"skip": metadata.skip, "skipReason": metadata.skipReason}; 226 {"skip": metadata.skip, "skipReason": metadata.skipReason};
226 227
227 /// A callback called when [liveTest] finishes running. 228 /// A callback called when [liveTest] finishes running.
228 void _onComplete(LiveTest liveTest) { 229 void _onComplete(LiveTest liveTest) {
229 _emit("testDone", { 230 _emit("testDone", {
230 "testID": _liveTestIDs[liveTest], 231 "testID": _liveTestIDs[liveTest],
231 "result": liveTest.state.result.toString(), 232 // For backwards-compatibility, report skipped tests as successes.
233 "result": liveTest.state.result == Result.skipped
234 ? "success"
235 : liveTest.state.result.toString(),
236 "skipped": liveTest.state.result == Result.skipped,
232 "hidden": !_engine.liveTests.contains(liveTest) 237 "hidden": !_engine.liveTests.contains(liveTest)
233 }); 238 });
234 } 239 }
235 240
236 /// A callback called when [liveTest] throws [error]. 241 /// A callback called when [liveTest] throws [error].
237 void _onError(LiveTest liveTest, error, StackTrace stackTrace) { 242 void _onError(LiveTest liveTest, error, StackTrace stackTrace) {
238 _emit("error", { 243 _emit("error", {
239 "testID": _liveTestIDs[liveTest], 244 "testID": _liveTestIDs[liveTest],
240 "error": error.toString(), 245 "error": error.toString(),
241 "stackTrace": terseChain(stackTrace, verbose: _verboseTrace).toString(), 246 "stackTrace": terseChain(stackTrace, verbose: _verboseTrace).toString(),
(...skipping 27 matching lines...)
269 GroupEntry entry, TestPlatform platform) { 274 GroupEntry entry, TestPlatform platform) {
270 var frame = entry.trace?.frames?.first; 275 var frame = entry.trace?.frames?.first;
271 if (!_jsLocations && platform.isJS) frame = null; 276 if (!_jsLocations && platform.isJS) frame = null;
272 277
273 map["line"] = frame?.line; 278 map["line"] = frame?.line;
274 map["column"] = frame?.column; 279 map["column"] = frame?.column;
275 map["url"] = frame?.uri?.toString(); 280 map["url"] = frame?.uri?.toString();
276 return map; 281 return map;
277 } 282 }
278 } 283 }
OLDNEW
« no previous file with comments | « lib/src/runner/reporter/expanded.dart ('k') | test/runner/engine_test.dart » ('j') | no next file with comments »

Powered by Google App Engine