Not sure if you can make runner.t work with prove without altering run.t.raw slightly. It will if you change the raw file to make the last line conditional in a similar way to this:
#!perl use strictures; use Test::More; subtest "Prod" => sub { plan skip_all => "Set PROD_TEST to run" unless $ENV{PROD_TEST}; ok 1, "OHAI, PROD!"; done_testing(1); }; subtest "Dev" => sub { plan skip_all => "Set DEV_TEST to run" unless $ENV{DEV_TEST}; ok 1, "OHAI, DEV!"; done_testing(1); }; done_testing(2) if $0 =~ /run\.t\.raw/;
Then the runner can just become
#!perl # File: runner.t use strictures; use Test::More; for my $env (qw/ PROD DEV /) { my $test = join "_", $env, "TEST"; local $ENV{$test} = 1; do 'run.t.raw'; } done_testing (4);
I don't know if that's good enough for your criteria? Here's what happens when I run these:
$ perl run.t.raw # Subtest: Prod 1..0 # SKIP Set PROD_TEST to run ok 1 # skip Set PROD_TEST to run # Subtest: Dev 1..0 # SKIP Set DEV_TEST to run ok 2 # skip Set DEV_TEST to run 1..2 $ prove run.t.raw run.t.raw .. ok All tests successful. Files=1, Tests=2, 0 wallclock secs ( 0.03 usr 0.01 sys + 0.02 cusr + 0.00 csys = 0.06 CPU) Result: PASS $ perl runner.t # Subtest: Prod ok 1 - OHAI, PROD! 1..1 ok 1 - Prod # Subtest: Dev 1..0 # SKIP Set DEV_TEST to run ok 2 # skip Set DEV_TEST to run # Subtest: Prod 1..0 # SKIP Set PROD_TEST to run ok 3 # skip Set PROD_TEST to run # Subtest: Dev ok 1 - OHAI, DEV! 1..1 ok 4 - Dev 1..4 $ prove runner.t runner.t .. ok All tests successful. Files=1, Tests=4, 0 wallclock secs ( 0.03 usr 0.00 sys + 0.02 cusr + 0.00 csys = 0.05 CPU) Result: PASS $
In reply to Re: Test runner that acts like a test and can be run as one
by hippo
in thread Test runner that acts like a test and can be run as one
by Your Mother
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |