Skip to content

Instantly share code, notes, and snippets.

Created August 19, 2015 02:33
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save anonymous/6607717a5d201a9acf82 to your computer and use it in GitHub Desktop.
sub MAIN($test-dir, *@source-dirs) {
react {
whenever IO::Notification.watch-path($test-dir) {
maybe-run-tests('Tests changed');
}
for @source-dirs -> $dir {
whenever IO::Notification.watch-path($dir) {
maybe-run-tests('Source changed');
}
}
whenever signal(SIGINT) {
say "Goodbye!";
exit;
}
sub maybe-run-tests($reason) {
state $running-tests = False;
unless $running-tests {
$running-tests = True;
my $runner = Proc::Async.new('cmd.exe', '/c', 'prove --exec="perl6-m -Ilib" ' ~ $test-dir);
whenever $runner.stdout -> $output {
print $output.indent(2);
}
whenever $runner.stderr { } # Discard
say "Running tests ($reason)";
my $completed = $runner.start;
whenever $completed {
print "\n\n";
$running-tests = False;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment