test urchin_root
This commit is contained in:
parent
160222c0eb
commit
83af249dcd
6
tests/Test root contains .urchin./Assess root with --root.
Executable file
6
tests/Test root contains .urchin./Assess root with --root.
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
observed=$(../../urchin --root .testsuite/a/b)
|
||||
expected=.testsuite/a/b/../..
|
||||
|
||||
test "$observed" = "$expected"
|
28
urchin
28
urchin
|
@ -16,6 +16,29 @@ unset CDPATH
|
|||
# Urchin version number
|
||||
VERSION=0.0.6
|
||||
|
||||
urchin_root() {
|
||||
(
|
||||
set -e
|
||||
if test -f "$1"; then
|
||||
set -- $(dirname "$1")
|
||||
fi
|
||||
cd "$1"
|
||||
if test -d .urchin; then
|
||||
echo "$1"
|
||||
elif test "$(readlink -f $1)" = /; then
|
||||
guess=$(readlink -f "$1"|sed s+\(/tests?/\).*+/tests/+)
|
||||
echo "You need to create the .urchin directory in the root of your tests,
|
||||
maybe like this:
|
||||
|
||||
mkdir '$guess'/.urchin
|
||||
" >&2
|
||||
else
|
||||
cd - > /dev/null
|
||||
urchin_root "$1"/..
|
||||
fi
|
||||
)
|
||||
}
|
||||
|
||||
fullpath() {
|
||||
(
|
||||
cd -- "$1"
|
||||
|
@ -191,6 +214,7 @@ $USAGE
|
|||
contain the word "test".
|
||||
-t Format output in Test Anything Protocol (TAP)
|
||||
-h, --help This help.
|
||||
-r, --root Print the Urchin root for a particular file or directory.
|
||||
-v Display the version number.
|
||||
|
||||
Go to https://github.com/tlevine/urchin for documentation on writing tests.
|
||||
|
@ -278,6 +302,10 @@ do
|
|||
case "$1" in
|
||||
-e) exit_on_fail=true;;
|
||||
-f) force=true;;
|
||||
-r|--root)
|
||||
shift
|
||||
urchin_root "$1"
|
||||
exit;;
|
||||
-s)
|
||||
shift
|
||||
shell_for_sh_tests=$1
|
||||
|
|
Loading…
Reference in New Issue
Block a user