Michael G Schwern wrote: > The attached proof-of-concept implements it. I had to poke at the guts of > TB to do it, there's no way to extend the plan without printing the plan, so > it would need a minor TB patch. But its very straight forward.
Figured out a way to not have to do that. Just temporarily turn on "no_header". New version attached. Feel free to take it and run.
package AsYouGo; use strict; use warnings; use base qw(Test::Builder::Module); our @EXPORT = qw(plan extend); my $Extended = 0; my $Is_As_You_Go = 0; use CLASS; sub plan { my($plan) = shift; my $tb = $CLASS->builder; if( $plan eq "as_you_go" ) { $Is_As_You_Go = 1; $tb->plan("no_plan"); } else { # pass through to TB $tb->plan(@_); } } sub extend { my($extra_tests) = shift; my $tb = $CLASS->builder; print "# Extending plan by $extra_tests\n"; $extra_tests-- unless $Extended; # there's already one # TB prints the plan when you set expected_tests() so we # suppress that. $tb->no_header(1); my $expected_tests = $tb->expected_tests; $tb->expected_tests($expected_tests + $extra_tests); $tb->no_header(0); $Extended = 1; 1; } END { if( $Is_As_You_Go && !$Extended ) { die "# An as_you_go plan declared but never extended!\n"; } } 1; __END__