Subject: | Severe Bug: tests run after bail_on_fail |
Date: | Fri, 15 May 2015 22:37:17 +0200 |
To: | bug-Test-Most [...] rt.cpan.org |
From: | Sebastian Rose <sebastian_rose [...] gmx.de> |
Hello maintainers,
I just (2015-05-15) installed Test::Most. I was especially interested
in the handy error handling features.
Unfortunately I found, what I consider a severe bug (on the first
glance). A few examples:
use Test::Most 'no_plan';
die_on_fail;
ok 1, 'Throw on fail';
restore_fail; # The error happens with and without this line.
bail_on_fail;
ok 0, 'BAIL_OUT on fail'; # Expected to stop testing immediately!
restore_fail;
ok 1, 'Dangerous test';
sh# prove t/test_most_error_handling.t -v
01 t/test_most_error_handling.t ..
02 ok 1 - Throw on fail
03 not ok 2 - BAIL_OUT on fail
04 ok 3 - Dangerous test - WILL BE EXECUTED
05 1..3
06 Bailout called. Further testing stopped: Test failed. BAIL OUT!.
07 Bail out! Test failed. BAIL OUT!.
08
09 # Failed test 'BAIL_OUT on fail'
10 # at t/test_most_error_handling.t line 9.
11 # Looks like you failed 1 test of 3.
12 FAILED--Further testing stopped: Test failed. BAIL OUT!.
NOTE lines 4 and 11! 3 Tests were executed - instead of 2. According
to the docs, this does not seem to be the intended behaviour (to me).
Here comes the behaviour that I would expect (triggering BAIL_OUT "by
hand"):
use Test::Most 'no_plan';
die_on_fail;
ok 1, 'Throw on fail';
bail_on_fail;
ok( 0, 'BAIL_OUT on fail' ) or BAIL_OUT(" S T O P ");
restore_fail;
ok 1, 'Dangerous test - WILL NOT BE EXECUTED';
sh# prove t/test_most_error_handling.t -v
01 t/test_most_error_handling.t ..
02 ok 1 - Throw on fail
03 not ok 2 - BAIL_OUT on fail
04 Bailout called. Further testing stopped: S T O P
05 Bail out! S T O P
06
07 # Failed test 'BAIL_OUT on fail'
08 # at t/test_most_error_handling.t line 7.
09 FAILED--Further testing stopped: S T O P
Only two tests executed. BAIL_OUT stopped the testing immediatly.
'Dangerous test' is NOT executed.
--
Ich setzte einen Fuß in die Luft, und sie trug.
(Hilde Domin)