Skip to content

Instantly share code, notes, and snippets.

@chriscz
Last active Jul 11, 2021
Embed
What would you like to do?
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