refactor
This commit is contained in:
parent
f0e034b91f
commit
a5176e1262
87
urchin
87
urchin
@ -1,6 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
stdout_file=/tmp/urchin_stdout
|
stdout_file=/tmp/urchin_stdout
|
||||||
|
logfile=$(readlink -f "$1/.urchin.log")
|
||||||
|
|
||||||
indent() {
|
indent() {
|
||||||
level="$1"
|
level="$1"
|
||||||
@ -68,6 +69,41 @@ recurse() {
|
|||||||
|
|
||||||
USAGE="usage: $0 <test directory>"
|
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
|
FORCE=false
|
||||||
HELP=false
|
HELP=false
|
||||||
while [ $# -gt 0 ]
|
while [ $# -gt 0 ]
|
||||||
@ -84,48 +120,17 @@ do
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
if $HELP
|
# Help first
|
||||||
then
|
$HELP && 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
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check
|
# Verify argument for main stuff
|
||||||
if [ "$#" = '1' ] && [ -d "$1" ]
|
[ "$#" = '1' ] && [ -d "$1" ] ||
|
||||||
|
( echo "$USAGE" && exit 1 )
|
||||||
|
|
||||||
|
# Run or present the Molly guard.
|
||||||
|
if echo "$(basename "$(readlink -f "$1")")" | grep test || $FORCE
|
||||||
then
|
then
|
||||||
sleep 0s
|
urchin_go "$1"
|
||||||
else
|
else
|
||||||
echo "$USAGE"
|
urchin_molly_guard
|
||||||
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
|
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user