Skip to content

Instantly share code, notes, and snippets.

@sunaku
Last active December 26, 2015 16:09
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 sunaku/7178353 to your computer and use it in GitHub Desktop.
Save sunaku/7178353 to your computer and use it in GitHub Desktop.
Event-driven test runners for Coursera Programming Languages class - https://class.coursera.org/proglang-002
#!/bin/sh
# When *.rkt files in the current directory are modified, this script runs
# their corresponding *test.rkt files and prints any errors or test fails.
inotifywait -qme close_write --format '%w%f' . | while read file; do
# only process *.rkt files - ignore all other files
test "${file%.rkt}" = "$file" && continue
# map the *.rkt file to its corresponding *test.rkt
# file, unless it already _is_ that *test.rkt file!
test "${file%test.rkt}" = "$file" && file="${file%.rkt}test.rkt"
# make sure *test.rkt file exists before running it
test -f "$file" || continue
# keep track of which test file is being run & when
echo "\033[36m$file @ $(date)\033[0m"
# run test file and print any errors or test fails
racket "$file"
done
#!/bin/sh
# When *.rb files in the current directory are modified, this script runs
# their corresponding *test.rb files and prints any errors or test fails.
inotifywait -qme close_write --format '%w%f' . | while read file; do
# only process *.rb files - ignore all other files
test "${file%.rb}" = "$file" && continue
# map the *.rb file to its corresponding *test.rb
# file, unless it already _is_ that *test.rb file!
test "${file%test.rb}" = "$file" && file="${file%.rb}test.rb"
# make sure *test.rb file exists before running it
test -f "$file" || continue
# keep track of which test file is being run & when
echo "\033[36m$file @ $(date)\033[0m"
# run test file and print any errors or test fails
ruby -w "$file"
done
#!/bin/sh
# When *.sml files in the current directory are modified, this script runs
# their corresponding *test.sml files and prints any errors or test fails.
inotifywait -qme close_write --format '%w%f' . | while read file; do
# only process *.sml files - ignore all other files
test "${file%.sml}" = "$file" && continue
# map the *.sml file to its corresponding *test.sml
# file, unless it already _is_ that *test.sml file!
test "${file%test.sml}" = "$file" && file="${file%.sml}test.sml"
# make sure *test.sml file exists before running it
test -f "$file" || continue
# keep track of which test file is being run & when
echo "\033[36m$file @ $(date)\033[0m"
# run test file and print any errors or test fails
sml "$file" </dev/null | sed -n \
-e '/ Error: /,$p' \
-e '/ Warning: /p' \
-e '/ = false : bool$/p' \
-e '/ = <hidden-value> : bool$/p'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment