Skip to content

Instantly share code, notes, and snippets.

@tommystanton
Last active May 7, 2018 00:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommystanton/5ec743bdbe915991d1b4d2d512a678c7 to your computer and use it in GitHub Desktop.
Save tommystanton/5ec743bdbe915991d1b4d2d512a678c7 to your computer and use it in GitHub Desktop.
Automatically run tests when a source file is modified (Perl 6)
#!/bin/bash
while inotifywait \
--quiet --quiet \
--recursive \
--event close_write \
lib/ @lib/.precomp/ bin/ t/; do \
clear; \
prove --exec perl6 --lib --verbose; \
done
@tommystanton
Copy link
Author

Dependencies

  • inotifywait is provided by the APT package inotify-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)

@MattOates
Copy link

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

@tommystanton
Copy link
Author

@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. 😁

@tommystanton
Copy link
Author

Another CLI program that I've come across, as an alternative to inotifywait(1), is entr(1). Seems more straightforward.

@tommystanton
Copy link
Author

tommystanton commented May 7, 2018

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