refactor
This commit is contained in:
parent
f0e034b91f
commit
a5176e1262
71
urchin
71
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,24 +69,7 @@ recurse() {
|
|||||||
|
|
||||||
USAGE="usage: $0 <test directory>"
|
USAGE="usage: $0 <test directory>"
|
||||||
|
|
||||||
FORCE=false
|
urchin_help() {
|
||||||
HELP=false
|
|
||||||
while [ $# -gt 0 ]
|
|
||||||
do
|
|
||||||
case "$1" in
|
|
||||||
-f) FORCE=true;;
|
|
||||||
-h) HELP=true;;
|
|
||||||
# --xsd) action=testsuite;;
|
|
||||||
# --) shift; break;;
|
|
||||||
-*) echo >&2 $USAGE
|
|
||||||
exit 1;;
|
|
||||||
*) break;;
|
|
||||||
esac
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
|
|
||||||
if $HELP
|
|
||||||
then
|
|
||||||
echo
|
echo
|
||||||
echo "$USAGE"
|
echo "$USAGE"
|
||||||
echo
|
echo
|
||||||
@ -97,30 +81,20 @@ if $HELP
|
|||||||
echo 'Go to http://www.urchin.sh for documentation on writing tests.'
|
echo 'Go to http://www.urchin.sh for documentation on writing tests.'
|
||||||
echo
|
echo
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
}
|
||||||
|
|
||||||
# Check
|
urchin_go() {
|
||||||
if [ "$#" = '1' ] && [ -d "$1" ]
|
|
||||||
then
|
|
||||||
sleep 0s
|
|
||||||
else
|
|
||||||
echo "$USAGE"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Go
|
|
||||||
if echo $(basename "$(readlink -f "$1")") | grep test || $FORCE
|
|
||||||
then
|
|
||||||
echo Running tests
|
echo Running tests
|
||||||
|
|
||||||
logfile=$(readlink -f "$1/.urchin.log")
|
|
||||||
echo > "$logfile"
|
echo > "$logfile"
|
||||||
recurse "$1" 0
|
recurse "$1" 0
|
||||||
|
|
||||||
echo Done
|
echo Done
|
||||||
echo $(grep -e 'passed$' "$logfile"|wc -l) tests passed.
|
echo $(grep -e 'passed$' "$logfile"|wc -l) tests passed.
|
||||||
echo $(grep -e 'failed$' "$logfile"|wc -l) tests failed.
|
echo $(grep -e 'failed$' "$logfile"|wc -l) tests failed.
|
||||||
else
|
}
|
||||||
|
|
||||||
|
urchin_molly_guard() {
|
||||||
echo
|
echo
|
||||||
echo 'The directory on which you are running urchin is not'
|
echo 'The directory on which you are running urchin is not'
|
||||||
echo 'called "test", so I am not running in case that'
|
echo 'called "test", so I am not running in case that'
|
||||||
@ -128,4 +102,35 @@ else
|
|||||||
echo 'to run urchin on that directory.'
|
echo 'to run urchin on that directory.'
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCE=false
|
||||||
|
HELP=false
|
||||||
|
while [ $# -gt 0 ]
|
||||||
|
do
|
||||||
|
case "$1" in
|
||||||
|
-f) FORCE=true;;
|
||||||
|
-h) HELP=true;;
|
||||||
|
# --xsd) action=testsuite;;
|
||||||
|
# --) shift; break;;
|
||||||
|
-*) echo >&2 $USAGE
|
||||||
|
exit 1;;
|
||||||
|
*) break;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
# Help first
|
||||||
|
$HELP && urchin_help
|
||||||
|
|
||||||
|
# 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
|
||||||
|
urchin_go "$1"
|
||||||
|
else
|
||||||
|
urchin_molly_guard
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user