Skip to content

Instantly share code, notes, and snippets.

@chriscz
Last active July 11, 2021 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chriscz/9cf5e72c75d30f644f7b321e9729d237 to your computer and use it in GitHub Desktop.
Save chriscz/9cf5e72c75d30f644f7b321e9729d237 to your computer and use it in GitHub Desktop.
Crystal Makefile which runs tests when files change
# Requires inotify-tools to be installed. On Ubuntu / Debian:
# sudo apt install inotify-tools
CRYSTAL=crystal
TEST_ARGS=--chaos --parallel 4 --verbose
SPEC_ARGS=--order=random --error-on-warnings --verbose
WATCH=src/**/*.cr spec/**/*.cr test/**/*.cr
# The make rule to use when running tests. Either spec or test
TEST_RULE=test
.PHONY: spec watch test
spec:
crystal spec $(SPEC_ARGS)
test:
bash -c 'shopt -s globstar; $(CRYSTAL) run test/**/*_test.cr -- $(TEST_ARGS)'
watch:
bash -c 'shopt -s globstar; while true; do inotifywait -e close_write $(WATCH); $(VERBOSE) make $(TEST_RULE); done'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment