From 7b964590dfbaf810e920226ee20af6a34cefaefe Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Tue, 21 Jul 2026 23:06:56 +0000 Subject: [PATCH 1/3] Only print debug URL when debugging Either `--coverage` and `--pause-after-load` are sufficient to enable the `debug` state for the test runner, but in the case of `--coverage` without interactive debugging the VM debugger URL is not relevant to the user. Change the condition used to decide whether to include this URL in the JSON reporter output to only when `--pause-after-load` is used. --- pkgs/test/CHANGELOG.md | 2 + pkgs/test/test/runner/json_reporter_test.dart | 81 +++++++++++++++++++ pkgs/test_core/CHANGELOG.md | 2 + .../src/runner/configuration/reporters.dart | 2 +- 4 files changed, 86 insertions(+), 1 deletion(-) diff --git a/pkgs/test/CHANGELOG.md b/pkgs/test/CHANGELOG.md index 1cbee81cc..fa768d33f 100644 --- a/pkgs/test/CHANGELOG.md +++ b/pkgs/test/CHANGELOG.md @@ -7,6 +7,8 @@ * Suppress dart2js compiler output for successful compiles. * Include output from passing tests messages within the `Passing tests` group in `GithubReporter`. +* Only include VM debugger in output when using interactive debugging, suppress + it when only using coverage. ## 1.31.2 diff --git a/pkgs/test/test/runner/json_reporter_test.dart b/pkgs/test/test/runner/json_reporter_test.dart index a984248a5..8f8f634d2 100644 --- a/pkgs/test/test/runner/json_reporter_test.dart +++ b/pkgs/test/test/runner/json_reporter_test.dart @@ -6,6 +6,7 @@ library; import 'dart:async'; +import 'dart:convert'; import 'dart:io'; import 'package:path/path.dart' as p; @@ -851,6 +852,86 @@ void customTest(String name, dynamic Function() testFn) => test(name, testFn); args: ['-p', 'chrome', '--js-trace'], ); }, tags: ['chrome']); + + test('does not emit debug events when --coverage is enabled', () async { + var tempDir = await Directory.systemTemp.createTemp('coverage_json_test'); + try { + await d.file('test.dart', ''' + import 'package:test/test.dart'; + void main() { + test('success', () {}); + } + ''').create(); + + var test = await runTest([ + 'test.dart', + '--coverage', + tempDir.path, + ], reporter: 'json'); + await test.shouldExit(0); + + var stdoutLines = await test.stdoutStream().toList(); + var events = [ + for (var line in stdoutLines) jsonDecode(line) as Map, + ]; + expect(events.where((e) => e['type'] == 'debug'), isEmpty); + } finally { + await tempDir.delete(recursive: true); + } + }); + + test('emits debug events when --pause-after-load is enabled', () async { + await d.file('test.dart', ''' + import 'package:test/test.dart'; + void main() { + test('success', () {}); + } + ''').create(); + + var test = await runTest([ + 'test.dart', + '--pause-after-load', + ], reporter: 'json'); + + await expectLater(test.stdout, emitsThrough(contains('"type":"debug"'))); + + test.stdin.writeln(); + await test.shouldExit(0); + }); + + test( + 'emits debug events when both --pause-after-load and --coverage are enabled', + () async { + var tempDir = await Directory.systemTemp.createTemp( + 'coverage_pause_json_test', + ); + try { + await d.file('test.dart', ''' + import 'package:test/test.dart'; + void main() { + test('success', () {}); + } + ''').create(); + + var test = await runTest([ + 'test.dart', + '--pause-after-load', + '--coverage', + tempDir.path, + ], reporter: 'json'); + + await expectLater( + test.stdout, + emitsThrough(contains('"type":"debug"')), + ); + + test.stdin.writeln(); + await test.shouldExit(0); + } finally { + await tempDir.delete(recursive: true); + } + }, + ); } /// Asserts that the tests defined by [tests] produce the JSON events in diff --git a/pkgs/test_core/CHANGELOG.md b/pkgs/test_core/CHANGELOG.md index d5a173403..5306a052d 100644 --- a/pkgs/test_core/CHANGELOG.md +++ b/pkgs/test_core/CHANGELOG.md @@ -4,6 +4,8 @@ * Suppress dart2js compiler output for successful compiles. * Include passing test messages within the `Passing tests` group in `GithubReporter`. +* Only include VM debugger in output when using interactive debugging, suppress + it when only using coverage. ## 0.6.19 diff --git a/pkgs/test_core/lib/src/runner/configuration/reporters.dart b/pkgs/test_core/lib/src/runner/configuration/reporters.dart index 1f8a1fd3f..c21cffacf 100644 --- a/pkgs/test_core/lib/src/runner/configuration/reporters.dart +++ b/pkgs/test_core/lib/src/runner/configuration/reporters.dart @@ -91,7 +91,7 @@ final _allReporters = { 'A machine-readable format (see ' 'https://dart.dev/go/test-docs/json_reporter.md).', (config, engine, sink) => - JsonReporter.watch(engine, sink, isDebugRun: config.debug), + JsonReporter.watch(engine, sink, isDebugRun: config.pauseAfterLoad), ), 'silent': ReporterDetails( 'A reporter with no output. ' From 5960ccd16a43be215140aa2e9e8f4d9559824726 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Wed, 22 Jul 2026 22:39:25 +0000 Subject: [PATCH 2/3] Skip pause-after-load tests on Windows --- pkgs/test/test/runner/json_reporter_test.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/test/test/runner/json_reporter_test.dart b/pkgs/test/test/runner/json_reporter_test.dart index 8f8f634d2..2d2b6fdff 100644 --- a/pkgs/test/test/runner/json_reporter_test.dart +++ b/pkgs/test/test/runner/json_reporter_test.dart @@ -897,7 +897,7 @@ void customTest(String name, dynamic Function() testFn) => test(name, testFn); test.stdin.writeln(); await test.shouldExit(0); - }); + }, testOn: '!windows'); test( 'emits debug events when both --pause-after-load and --coverage are enabled', @@ -931,6 +931,7 @@ void customTest(String name, dynamic Function() testFn) => test(name, testFn); await tempDir.delete(recursive: true); } }, + testOn: '!windows', ); } From c6799303f835160da01bbee3145dec86d459d002 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Wed, 22 Jul 2026 22:42:17 +0000 Subject: [PATCH 3/3] Add TODO comment linking issue 1613 to testOn arguments --- pkgs/test/test/runner/json_reporter_test.dart | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/pkgs/test/test/runner/json_reporter_test.dart b/pkgs/test/test/runner/json_reporter_test.dart index 2d2b6fdff..8d6913e80 100644 --- a/pkgs/test/test/runner/json_reporter_test.dart +++ b/pkgs/test/test/runner/json_reporter_test.dart @@ -880,24 +880,29 @@ void customTest(String name, dynamic Function() testFn) => test(name, testFn); } }); - test('emits debug events when --pause-after-load is enabled', () async { - await d.file('test.dart', ''' + test( + 'emits debug events when --pause-after-load is enabled', + () async { + await d.file('test.dart', ''' import 'package:test/test.dart'; void main() { test('success', () {}); } ''').create(); - var test = await runTest([ - 'test.dart', - '--pause-after-load', - ], reporter: 'json'); + var test = await runTest([ + 'test.dart', + '--pause-after-load', + ], reporter: 'json'); - await expectLater(test.stdout, emitsThrough(contains('"type":"debug"'))); + await expectLater(test.stdout, emitsThrough(contains('"type":"debug"'))); - test.stdin.writeln(); - await test.shouldExit(0); - }, testOn: '!windows'); + test.stdin.writeln(); + await test.shouldExit(0); + }, + // TODO(https://github.com/dart-lang/test/issues/1613): Fix pause after load tests on windows. + testOn: '!windows', + ); test( 'emits debug events when both --pause-after-load and --coverage are enabled', @@ -931,6 +936,7 @@ void customTest(String name, dynamic Function() testFn) => test(name, testFn); await tempDir.delete(recursive: true); } }, + // TODO(https://github.com/dart-lang/test/issues/1613): Fix pause after load tests on windows. testOn: '!windows', ); }