This commit is contained in:
Thomas Levine 2012-10-11 02:21:05 -04:00
parent f0e034b91f
commit a5176e1262

87
urchin
View File

@ -1,6 +1,7 @@
#!/bin/bash
stdout_file=/tmp/urchin_stdout
logfile=$(readlink -f "$1/.urchin.log")
indent() {
level="$1"
@ -68,6 +69,41 @@ recurse() {
USAGE="usage: $0 <test directory>"
urchin_help() {
echo
echo "$USAGE"
echo
echo '-f Force urchin to run on directories not named "test".'
echo '-h This help'
echo
echo '--xsd Output xUnit XML schema for an integration server.'
echo
echo 'Go to http://www.urchin.sh for documentation on writing tests.'
echo
exit 0
}
urchin_go() {
echo Running tests
echo > "$logfile"
recurse "$1" 0
echo Done
echo $(grep -e 'passed$' "$logfile"|wc -l) tests passed.
echo $(grep -e 'failed$' "$logfile"|wc -l) tests failed.
}
urchin_molly_guard() {
echo
echo 'The directory on which you are running urchin is not'
echo 'called "test", so I am not running in case that'
echo 'was an accident. Use the -f flag if you really want'
echo 'to run urchin on that directory.'
echo
exit 1
}
FORCE=false
HELP=false
while [ $# -gt 0 ]
@ -84,48 +120,17 @@ do
shift
done
if $HELP
then
echo
echo "$USAGE"
echo
echo '-f Force urchin to run on directories not named "test".'
echo '-h This help'
echo
echo '--xsd Output xUnit XML schema for an integration server.'
echo
echo 'Go to http://www.urchin.sh for documentation on writing tests.'
echo
exit 0
fi
# Help first
$HELP && urchin_help
# Check
if [ "$#" = '1' ] && [ -d "$1" ]
# Verify argument for main stuff
[ "$#" = '1' ] && [ -d "$1" ] ||
( echo "$USAGE" && exit 1 )
# Run or present the Molly guard.
if echo "$(basename "$(readlink -f "$1")")" | grep test || $FORCE
then
sleep 0s
urchin_go "$1"
else
echo "$USAGE"
exit 1
fi
# Go
if echo $(basename "$(readlink -f "$1")") | grep test || $FORCE
then
echo Running tests
logfile=$(readlink -f "$1/.urchin.log")
echo > "$logfile"
recurse "$1" 0
echo Done
echo $(grep -e 'passed$' "$logfile"|wc -l) tests passed.
echo $(grep -e 'failed$' "$logfile"|wc -l) tests failed.
else
echo
echo 'The directory on which you are running urchin is not'
echo 'called "test", so I am not running in case that'
echo 'was an accident. Use the -f flag if you really want'
echo 'to run urchin on that directory.'
echo
exit 1
urchin_molly_guard
fi