|
581 | 581 | -type short_module_result() :: [mfa()] | error().
|
582 | 582 | -type module_result() :: long_module_result() | short_module_result().
|
583 | 583 | -type shrinking_result() :: {non_neg_integer(),imm_testcase()}.
|
| 584 | +-type shrinking_states() :: 'false' | 'true' | 'done'. |
584 | 585 |
|
585 | 586 | %%-----------------------------------------------------------------------------
|
586 | 587 | %% State handling functions
|
@@ -1701,11 +1702,23 @@ finalize_input(Instance) ->
|
1701 | 1702 | %% Shrinking functions
|
1702 | 1703 | %%-----------------------------------------------------------------------------
|
1703 | 1704 |
|
| 1705 | +-spec set_shrinking_param(shrinking_states()) -> ok. |
| 1706 | +set_shrinking_param(Val) -> |
| 1707 | + OldParams = erlang:get('$parameters'), |
| 1708 | + case OldParams of |
| 1709 | + undefined -> |
| 1710 | + erlang:put('$parameters', [{shrinking, Val}]); |
| 1711 | + _ -> |
| 1712 | + erlang:put('$parameters', [{shrinking, Val} | OldParams]) |
| 1713 | + end, |
| 1714 | + ok. |
| 1715 | + |
1704 | 1716 | -spec shrink(imm_testcase(), test(), fail_reason(), opts()) ->
|
1705 | 1717 | {'ok',imm_testcase()} | error().
|
1706 | 1718 | shrink(ImmTestCase, Test, Reason,
|
1707 | 1719 | #opts{expect_fail = false, noshrink = false, max_shrinks = MaxShrinks,
|
1708 | 1720 | output_fun = Print, nocolors = NoColors} = Opts) ->
|
| 1721 | + set_shrinking_param(true), % needs to be set before printing |
1709 | 1722 | case NoColors of
|
1710 | 1723 | true ->
|
1711 | 1724 | Print("~nShrinking ", []);
|
@@ -1736,10 +1749,12 @@ shrink(ImmTestCase, Test, Reason,
|
1736 | 1749 | end
|
1737 | 1750 | catch
|
1738 | 1751 | throw:non_boolean_result ->
|
| 1752 | + set_shrinking_param(done), |
1739 | 1753 | Print("~n", []),
|
1740 | 1754 | {error, non_boolean_result}
|
1741 | 1755 | end;
|
1742 | 1756 | shrink(ImmTestCase, _Test, _Reason, _Opts) ->
|
| 1757 | + set_shrinking_param(done), |
1743 | 1758 | {ok, ImmTestCase}.
|
1744 | 1759 |
|
1745 | 1760 | -spec fix_shrink(imm_testcase(), stripped_test(), fail_reason(),
|
@@ -2125,6 +2140,7 @@ report_shrinking(Shrinks, MinImmTestCase, MinActions, Print, NoColors) ->
|
2125 | 2140 | true -> Print("(~b time(s))~n", [Shrinks]);
|
2126 | 2141 | false -> Print("\033[01;34m(~b time(s))\033[00m~n", [Shrinks])
|
2127 | 2142 | end,
|
| 2143 | + set_shrinking_param(done), |
2128 | 2144 | print_imm_testcase(MinImmTestCase, "", Print),
|
2129 | 2145 | execute_actions(MinActions).
|
2130 | 2146 |
|
|
0 commit comments