note
adrianh
tests
testing
test
suite
I have this sitting in my ~/bin
<code>
#! /usr/bin/perl -w
# onchange file ... command
# run command if any of the given files/directories
# change
use strict;
use warnings;
use File::Find;
use Digest::MD5;
my $Command = pop @ARGV;
my $Files = [@ARGV];
my $Last_digest = '';
sub has_changed {
my $files = shift;
my $ctx = Digest::MD5->new;
find(sub {$ctx->add($File::Find::name, (stat($_))[9])}, grep {-e $_} @$files);
my $digest = $ctx->digest;
my $has_changed = $digest ne $Last_digest;
$Last_digest = $digest;
return($has_changed);
};
while (1) {
system($Command) if has_changed($Files);
sleep 1;
};
</code>
<p>I have this in my <code>.cshrc</code></p>
<code>
alias testwatch "onchange Makefile.PL Makefile */*.pod */*.pm *.pm t test.pl 'clear; make test \!*'"
</code>
<p>I then type <code>% testwatch</code> or <code>% testwatch TEST_VERBOSE=1</code> in the root directory of any module I'm messing with.
This won't work 100% of the time but hits that 80/20 spot for me.</p>
<p>I have a little todo list on an improved test monitor that I will, when some of that mythical free time comes along, implement. Now we have the lovely [CPAN://Test::Harness::Straps] it's not even that difficult.</p>
189148
189284