in reply to prove --state=failed,save

--state operates on files, not individual tests, as they can depend on each other (even if it's a bad practice we should avoid).

If you only want to run the failed tests, don't tell prove to run anything else:

$ prove --state=failed t/02.t .. 1/1 # Failed test 'B' # at t/02.t line 2. # Looks like you failed 1 test of 1. t/02.t .. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/1 subtests t/04.t .. 1/1 # Failed test 'D' # at t/04.t line 2. # Looks like you failed 1 test of 1. t/04.t .. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/1 subtests Test Summary Report ------------------- t/02.t (Wstat: 256 Tests: 1 Failed: 1) Failed test: 1 Non-zero exit status: 1 t/04.t (Wstat: 256 Tests: 1 Failed: 1) Failed test: 1 Non-zero exit status: 1 Files=2, Tests=2, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.08 cusr + 0.00 csys = 0.10 CPU) Result: FAIL

By appending t to the command line, you told prove to run all the tests in t/ together with the failed ones.

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: prove --state=failed,save
by 1nickt (Canon) on Feb 25, 2018 at 23:35 UTC

    Thank you choroba, Bravo!! (you went from "choroba has never used --state" to figuring the answer out rather quickly ;-)

    Update: Although it seems to be not quite true that "By appending t to the command line, you told prove to run all the tests in t/ together with the failed ones." ... apparently prove skips from the directory any test files that have already been run via failed.

    Since I never rely on prove's looking for t/ by default it did not occur to me that the examples in the doc are showing complete commands.

    I think --state would be more useful for me if it applied to individual tests within files (and within subtests even!) Maybe a plugin is called for.


    The way forward always starts with a minimal test.