Subject: | Add option to rebuild on change, maybe do it automatically |
Test::Continuous works on the assumption that there is no build step.
That your code can change and the tests will still work. This is not
generally applicable.
It would be handy if you could give runtests() a command to execute
before running prove. This would likely be as simple as "./Build" or
"make".
It would be more convenient if autoprove did this automatically. It
could detect the existence of a build system:
if( -e "Build.PL" ) {
$build{cmd} = './Build';
$build{config} = 'Build.PL';
}
elsif( -e "Makefile.PL" ) {
$build{cmd} = 'make';
$build{config} = 'Makefile.PL';
}
And then run it on change.
while ( my @changes = $watcher->wait_for_events() ) {
print "[MSG]:" . $_->path . " was changed.\n" for @changes;
rebuild(\@changes);
_run_once;
sleep 3;
}
sub rebuild {
my $changes = shift;
# Rerun the config file if it changed or hasn't been run
if( !-e $build{cmd} or
grep { $_ eq $build{config} } @$changes
)
{
my $cmd = "$^X $build{config}";
system $cmd;
die "$cmd exited with non-zero" unless $? == 0;
}
system $build{cmd};
die "$build{cmd} exited with non-zero" unless $? == 0;
}