Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkgs/test/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
88 changes: 88 additions & 0 deletions pkgs/test/test/runner/json_reporter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
library;

import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:path/path.dart' as p;
Expand Down Expand Up @@ -851,6 +852,93 @@ 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<String, dynamic>,
];
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);
},
// 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',
() 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);
}
},
// TODO(https://github.com/dart-lang/test/issues/1613): Fix pause after load tests on windows.
testOn: '!windows',
);
}

/// Asserts that the tests defined by [tests] produce the JSON events in
Expand Down
2 changes: 2 additions & 0 deletions pkgs/test_core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ final _allReporters = <String, ReporterDetails>{
'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. '
Expand Down
Loading