Skip to content

Instantly share code, notes, and snippets.

@jshirley
Created July 9, 2012 18:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jshirley/3078067 to your computer and use it in GitHub Desktop.
Save jshirley/3078067 to your computer and use it in GitHub Desktop.
Automatically run tests when a file is modified
use Filesys::Notify::Simple;
use App::Prove;
use lib qw(lib);
my $tests = @ARGV;
my $watcher = Filesys::Notify::Simple->new([ './lib', './t/lib' ]);
my $prove = App::Prove->new;
while ( 1 ) {
$watcher->wait(sub {
for my $event ( @_ ) {
print "Edit for $event->{path}\n";
}
$prove->process_args(@ARGV);
$prove->run;
});
}

What I wanted

I wanted a way to just run tests, any number of them, just like prove. But when I save files.

It's annoying to have to manually do anything other than save a file to trigger a run.

Now I have it! It's just prove arguments, so anything works:

perl ci.pl --lib lib t/mytest.t

How I want it to be better

Right now the events queue up and stack up. I'd like it to behave in a better queue fashion, where if the method is working it won't re-queue blindly.

Feel free to fork and improve it!

Or...

Point me to a better solution that is already out there! A quick search didn't reveal anything though.

@jshirley
Copy link
Author

jshirley commented Jul 9, 2012

@sartak mentioned on Twitter to look at https://metacpan.org/module/Test::Continuous, which has an autoprove which works well except that it is eating input plus there is no way to disable Growl notifications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment