Skip to content

Commit

Permalink
Add a default onLog behavior with printOnFailure (#3494)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
natebosch committed May 4, 2023
1 parent ad15533 commit d3a9ecf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions build_test/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.2.0-wip

- Forward logs from `testBuilder` to `printOnFailure` by default.

## 2.1.7

- Allow the latest test_core (version 5.x).
Expand Down
1 change: 1 addition & 0 deletions build_test/lib/src/test_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ Future testBuilder(
void Function(LogRecord log)? onLog,
void Function(AssetId, Iterable<AssetId>)? reportUnusedAssetsForInput,
PackageConfig? packageConfig}) async {
onLog ??= (log) => printOnFailure('$log');
writer ??= InMemoryAssetWriter();

var inputIds = {
Expand Down
2 changes: 1 addition & 1 deletion build_test/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: build_test
description: Utilities for writing unit tests of Builders.
version: 2.1.7
version: 2.2.0-wip
repository: https://github.com/dart-lang/build/tree/master/build_test

environment:
Expand Down

0 comments on commit d3a9ecf

Please sign in to comment.