Skip to content

Commit

Permalink
Handle bad test instantiators
Browse files Browse the repository at this point in the history
  • Loading branch information
eproxus committed Sep 5, 2023
1 parent bd89278 commit 005ec56
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ The format is based on [Keep a Changelog], and this project adheres to

## [Unreleased]

## [0.4.2] - 2023-09-05

### Fixed

- Handle bad test instantiators (thanks @rlipscombe & @danfilip!)

## [0.4.1] - 2023-09-04

### Fixed
Expand Down
12 changes: 11 additions & 1 deletion src/unite_compact.erl
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,17 @@ format_info(Failure, {abort, {generator_failed, {MFA, {E, R, ST}}}}) ->
color:yellow(format_exception(E, R, ST))
]
};
format_info(Failure, {abort, {{bad_instantiator, {{M, F, A}, Result}}, {E, R, ST}}}) ->
Location = {M, F, A, []},
{
color:yellow(format_case(Failure, [Location|ST])),
[
color:yellowb(io_lib:format("Bad test instantiator: ~p~n", [
Result
])),
color:yellow(format_exception(E, R, ST))
]
};
format_info(Failure, {abort, {Reason, {E, R, ST}}}) ->
{
color:yellow(format_case(Failure, ST)),
Expand All @@ -230,7 +241,6 @@ format_info(Failure, {abort, {Reason, {E, R, ST}}}) ->
setup_failed -> "Setup failed: ";
cleanup_failed -> "Cleanup failed: ";
instantiation_failed -> "Instantiation failed: ";
bad_instantiator -> "Bad test representation: ";
Other -> io_lib:format("Unknown failure reason (~p): ", [Other])
end),
io_lib:format("~n", []),
Expand Down
1 change: 1 addition & 0 deletions test/unite_demo_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ long_test() -> timer:sleep(250).

short_test() -> timer:sleep(50).

bad_test_instantiator_test_() -> {foreach, fun() -> ok end, [fun(_) -> ok end]}.

io_format_test() ->
% If a control code sneaks into the stack trace, we have to make sure we can
Expand Down

0 comments on commit 005ec56

Please sign in to comment.