Last active
May 7, 2018 00:03
-
-
Save tommystanton/5ec743bdbe915991d1b4d2d512a678c7 to your computer and use it in GitHub Desktop.
Automatically run tests when a source file is modified (Perl 6)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while inotifywait \ | |
--quiet --quiet \ | |
--recursive \ | |
--event close_write \ | |
lib/ @lib/.precomp/ bin/ t/; do \ | |
clear; \ | |
prove --exec perl6 --lib --verbose; \ | |
done |
You might want to check out this Perl 6 presentation where Jonathan Worthington builds a test runner that watches your source directories via OS events all with Perl 6 http://jnthn.net/papers/2015-yapcasia-concurrency.pdf and the video https://youtu.be/JpqnNCx7wVY?t=1518
@MattOates: Thanks for the suggestion! 😄 👍
I wasn't aware of that slide in the talk, and it looks like IO::Notification is in the official documentation. 😁
Another CLI program that I've come across, as an alternative to inotifywait(1)
, is entr(1)
. Seems more straightforward.
I believe one way to achieve the same setup using entr(1)
is something like:
$ ls bin/* lib/*.pm6 t/*.t | entr -cr prove --exec perl6 -v
Also, replacing the ls ...
idea with git ls-tree --name-only -r HEAD
may also prove useful.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dependencies
inotifywait
is provided by the APT packageinotify-tools
in Debian and in Ubuntu.prove
is a Perl 5 program provided by the CPAN module App::Prove (fortunately, that ships with Debian/Ubuntu)