Skip to content

Instantly share code, notes, and snippets.

@yngwie74
Created December 15, 2017 00:48
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 yngwie74/86ceedf5a69b44693eee5828a15b995d to your computer and use it in GitHub Desktop.
Save yngwie74/86ceedf5a69b44693eee5828a15b995d to your computer and use it in GitHub Desktop.
Continuous testing with NUnit/GitBash
#!/bin/bash
_CURRENT_HASH="_new_stat.bak"
_PREVIOUS_HASH="_old_stat.bak"
_ANY_HASH="_???_stat.bak"
function pause() {
local key
read -t$1 -N1 -p"$2" key
case "$key" in
[qQ]) return 1 ;;
[rR]) return 2 ;;
*) return 0 ;;
esac
}
function run_tests() {
clear
[[ $run_immediately -eq 0 ]] && pause 5 "tests launching in 5 seconds... "
find ../output/ -type f -iname "*test*.dll" \( -not -iname "*accept*" \) -print0 | xargs -0 nice ~/nunit/nunit3-console.exe --shadowcopy #--labels=All
[[ -f TestResult.xml ]] && rm TestResult.xml
}
run_immediately=1
while true; do
stat -t ../output/ > ${_CURRENT_HASH}
if [[ ! -f ${_PREVIOUS_HASH} ]]; then
run_tests
else
# if differences found, go on to re-test
diff -q ${_CURRENT_HASH} ${_PREVIOUS_HASH} > /dev/null || run_tests
fi
run_immediately=0
mv ${_CURRENT_HASH} ${_PREVIOUS_HASH}
pause 90 "w"
case $? in
1) break
;;
2) rm ${_PREVIOUS_HASH}
run_immediately=1
;;
0) continue
;;
esac
done
find . -maxdepth 1 -type f -name "${_ANY_HASH}" -delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment