Skip to content

Instantly share code, notes, and snippets.

@genehack
Forked from jshirley/ci.pl
Created July 9, 2012 19:31
Show Gist options
  • Save genehack/3078393 to your computer and use it in GitHub Desktop.
Save genehack/3078393 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 $watcher = Filesys::Notify::Simple->new([ './lib', './t/lib' ]);
my $prove = App::Prove->new;
while ( 1 ) {
$watcher->wait(sub {
print "Edit for $_->{path}\n" for @_;
$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.

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