Skip to content

Commit d3a9ecf

Browse files
authored
Add a default onLog behavior with printOnFailure (#3494)
In `testBuilder`, if there was no `onLog` passed, use `printOnFailure` by default. This is the most useful behavior, and all use cases that aren't otherwise testing the logs specifically would benefit from seeing the output on test failure.
1 parent ad15533 commit d3a9ecf

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

build_test/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.2.0-wip
2+
3+
- Forward logs from `testBuilder` to `printOnFailure` by default.
4+
15
## 2.1.7
26

37
- Allow the latest test_core (version 5.x).

build_test/lib/src/test_builder.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ Future testBuilder(
135135
void Function(LogRecord log)? onLog,
136136
void Function(AssetId, Iterable<AssetId>)? reportUnusedAssetsForInput,
137137
PackageConfig? packageConfig}) async {
138+
onLog ??= (log) => printOnFailure('$log');
138139
writer ??= InMemoryAssetWriter();
139140

140141
var inputIds = {

build_test/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: build_test
22
description: Utilities for writing unit tests of Builders.
3-
version: 2.1.7
3+
version: 2.2.0-wip
44
repository: https://github.com/dart-lang/build/tree/master/build_test
55

66
environment:

0 commit comments

Comments
 (0)