-
Notifications
You must be signed in to change notification settings - Fork 16
/
inotifytest-sml
executable file
·32 lines (25 loc) · 1020 Bytes
/
inotifytest-sml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh
#
# When *.sml files in or under this folder are modified, this script runs
# their corresponding *test.sml files and prints any errors or test fails.
#
# Written in 2013 by Suraj N. Kurapati <https://github.com/sunaku>
inotifywait -rqme close_write --format '%w%f' . | while read -r 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=$(ls "${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
clear
printf '\033[36m%s @ %s\033[0m\n' "$file" "$(date)"
# 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'
} </dev/null
done