581581-type short_module_result () :: [mfa ()] | error ().
582582-type module_result () :: long_module_result () | short_module_result ().
583583-type shrinking_result () :: {non_neg_integer (),imm_testcase ()}.
584+ -type shrinking_states () :: 'false' | 'true' | 'done' .
584585
585586% %-----------------------------------------------------------------------------
586587% % State handling functions
@@ -1701,11 +1702,23 @@ finalize_input(Instance) ->
17011702% % Shrinking functions
17021703% %-----------------------------------------------------------------------------
17031704
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+
17041716-spec shrink (imm_testcase (), test (), fail_reason (), opts ()) ->
17051717 {'ok' ,imm_testcase ()} | error ().
17061718shrink (ImmTestCase , Test , Reason ,
17071719 # opts {expect_fail = false , noshrink = false , max_shrinks = MaxShrinks ,
17081720 output_fun = Print , nocolors = NoColors } = Opts ) ->
1721+ set_shrinking_param (true ), % needs to be set before printing
17091722 case NoColors of
17101723 true ->
17111724 Print (" ~n Shrinking " , []);
@@ -1719,27 +1732,32 @@ shrink(ImmTestCase, Test, Reason,
17191732 {Shrinks ,MinImmTestCase } ->
17201733 case rerun (Test , true , MinImmTestCase ) of
17211734 # fail {actions = MinActions } ->
1722- report_shrinking (Shrinks , MinImmTestCase , MinActions ,
1723- Print , NoColors ),
1735+ set_shrinking_param (done ),
1736+ report_shrinking (Shrinks , MinImmTestCase , MinActions ,
1737+ Print , NoColors ),
17241738 {ok , MinImmTestCase };
17251739 % % The cases below should never occur for deterministic tests.
17261740 % % When they do happen, we have no choice but to silently
17271741 % % skip the fail actions.
17281742 # pass {} ->
1729- report_shrinking (Shrinks , MinImmTestCase , [], Print ,
1730- NoColors ),
1743+ set_shrinking_param (done ),
1744+ report_shrinking (Shrinks , MinImmTestCase , [], Print ,
1745+ NoColors ),
17311746 {ok , MinImmTestCase };
17321747 {error ,_Reason } ->
1733- report_shrinking (Shrinks , MinImmTestCase , [], Print ,
1734- NoColors ),
1748+ set_shrinking_param (done ),
1749+ report_shrinking (Shrinks , MinImmTestCase , [], Print ,
1750+ NoColors ),
17351751 {ok , MinImmTestCase }
17361752 end
17371753 catch
17381754 throw :non_boolean_result ->
1755+ set_shrinking_param (done ),
17391756 Print (" ~n " , []),
17401757 {error , non_boolean_result }
17411758 end ;
17421759shrink (ImmTestCase , _Test , _Reason , _Opts ) ->
1760+ set_shrinking_param (done ),
17431761 {ok , ImmTestCase }.
17441762
17451763-spec fix_shrink (imm_testcase (), stripped_test (), fail_reason (),
0 commit comments