Compare commits
1 Commits
exit-on-fa
...
stop-on-fa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
27b5e88bde |
@@ -1,2 +0,0 @@
|
|||||||
Totally different syntax and similar features, plus TAP output
|
|
||||||
https://github.com/sstephenson/bats
|
|
||||||
@@ -6,7 +6,7 @@ for shell in dash bash ksh zsh; do
|
|||||||
if which $shell > /dev/null 2> /dev/null; then
|
if which $shell > /dev/null 2> /dev/null; then
|
||||||
echo
|
echo
|
||||||
echo Running urchin tests in $shell
|
echo Running urchin tests in $shell
|
||||||
$shell urchin -s $shell tests | tail -n 3
|
$shell urchin tests | tail -n 3
|
||||||
else
|
else
|
||||||
echo
|
echo
|
||||||
echo Skipping $shell because it is not in the PATH
|
echo Skipping $shell because it is not in the PATH
|
||||||
|
|||||||
@@ -172,9 +172,3 @@ It might make sense if you do this.
|
|||||||
## Alternatives to Urchin
|
## Alternatives to Urchin
|
||||||
Alternatives to Urchin are discussed in
|
Alternatives to Urchin are discussed in
|
||||||
[this blog post](https://blog.scraperwiki.com/2012/12/how-to-test-shell-scripts/).
|
[this blog post](https://blog.scraperwiki.com/2012/12/how-to-test-shell-scripts/).
|
||||||
|
|
||||||
## Ideas for new features
|
|
||||||
|
|
||||||
* Support [Nagios plugins](https://nagios-plugins.org/doc/guidelines.html)
|
|
||||||
* Stop running if a test fails so one can use Urchin as a
|
|
||||||
[setup framework](https://github.com/tlevine/urchin/issues/16).
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
false
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
false
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
false
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
tmp=$(mktemp)
|
|
||||||
../urchin -e -f ./.die-on-fail > $tmp
|
|
||||||
result=$?
|
|
||||||
|
|
||||||
grep '1 should run.' $tmp
|
|
||||||
grep '2 should run.' $tmp
|
|
||||||
grep -v '3 should not run.' $tmp
|
|
||||||
grep -v '4 should not run.' $tmp
|
|
||||||
|
|
||||||
rm $tmp
|
|
||||||
exit $result
|
|
||||||
3
tests/urchin -x should start the $TEST_SHELL.
Executable file
3
tests/urchin -x should start the $TEST_SHELL.
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
test c = $(../urchin -x .print-arg-3 a 'b b b b' c d e)
|
||||||
26
urchin
26
urchin
@@ -47,13 +47,6 @@ recurse() {
|
|||||||
|
|
||||||
# $2 instead of $indent_level so it doesn't clash
|
# $2 instead of $indent_level so it doesn't clash
|
||||||
recurse "${test}" $(( $2 + 1 )) "$shell_for_sh_tests"
|
recurse "${test}" $(( $2 + 1 )) "$shell_for_sh_tests"
|
||||||
exit_code=$?
|
|
||||||
|
|
||||||
if $exit_on_fail && test $exit_code -ne 0; then
|
|
||||||
[ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file"
|
|
||||||
[ -f teardown_dir ] && [ -x teardown_dir ] && ./teardown_dir >> "$stdout_file"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
[ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file"
|
[ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file"
|
||||||
done
|
done
|
||||||
@@ -74,6 +67,7 @@ recurse() {
|
|||||||
fi
|
fi
|
||||||
exit_code="$?"
|
exit_code="$?"
|
||||||
|
|
||||||
|
|
||||||
[ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file"
|
[ -f teardown ] && [ -x teardown ] && ./teardown >> "$stdout_file"
|
||||||
|
|
||||||
indent $indent_level
|
indent $indent_level
|
||||||
@@ -92,10 +86,6 @@ recurse() {
|
|||||||
cat "$stdout_file"
|
cat "$stdout_file"
|
||||||
printf '\033[0m'
|
printf '\033[0m'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $exit_on_fail && test 0 -ne $exit_code; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
[ $indent_level -eq 0 ] && rm "$stdout_file"
|
[ $indent_level -eq 0 ] && rm "$stdout_file"
|
||||||
}
|
}
|
||||||
@@ -115,9 +105,6 @@ $USAGE
|
|||||||
|
|
||||||
-s <shell> Invoke test scripts that either have no shebang line at all or
|
-s <shell> Invoke test scripts that either have no shebang line at all or
|
||||||
have shebang line "#!/bin/sh" with the specified shell.
|
have shebang line "#!/bin/sh" with the specified shell.
|
||||||
-e Stop running if any single test fails. This is helpful if you want
|
|
||||||
to use Urchin to run things other than tests, such as a set of
|
|
||||||
configuration scripts.
|
|
||||||
-f Force running even if the test directory's name does not
|
-f Force running even if the test directory's name does not
|
||||||
contain the word "test".
|
contain the word "test".
|
||||||
-h This help.
|
-h This help.
|
||||||
@@ -125,6 +112,10 @@ $USAGE
|
|||||||
Go to https://github.com/tlevine/urchin for documentation on writing tests.
|
Go to https://github.com/tlevine/urchin for documentation on writing tests.
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
# [Experimental -x option left undocumented for now.]
|
||||||
|
# -x [Experimental; not meant for direct invocation, but for use in
|
||||||
|
# the shebang line of test scripts]
|
||||||
|
# Run with "\$TEST_SHELL", falling back on /bin/sh.
|
||||||
}
|
}
|
||||||
|
|
||||||
plural () {
|
plural () {
|
||||||
@@ -183,17 +174,20 @@ urchin_molly_guard() {
|
|||||||
|
|
||||||
shell_for_sh_tests=
|
shell_for_sh_tests=
|
||||||
force=false
|
force=false
|
||||||
exit_on_fail=false
|
|
||||||
while [ $# -gt 0 ]
|
while [ $# -gt 0 ]
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-e) exit_on_fail=true;;
|
|
||||||
-f) force=true;;
|
-f) force=true;;
|
||||||
-s)
|
-s)
|
||||||
shift
|
shift
|
||||||
shell_for_sh_tests=$1
|
shell_for_sh_tests=$1
|
||||||
which "$shell_for_sh_tests" >/dev/null || { echo "Cannot find specified shell: '$shell_for_sh_tests'" >&2; urchin_help >&2; exit 2; }
|
which "$shell_for_sh_tests" >/dev/null || { echo "Cannot find specified shell: '$shell_for_sh_tests'" >&2; urchin_help >&2; exit 2; }
|
||||||
;;
|
;;
|
||||||
|
-x) # [EXPERIMENTAL; UNDOCUMENTED FOR NOW] `urchin -x <test-script>` in a test script's shebang line is equivalent to invoking that script with `"$TEST_SHELL" <test-script>`
|
||||||
|
shift
|
||||||
|
urchinsh=${TEST_SHELL:-/bin/sh}
|
||||||
|
"$urchinsh" "$@"
|
||||||
|
exit $?;;
|
||||||
-h|--help) urchin_help
|
-h|--help) urchin_help
|
||||||
exit 0;;
|
exit 0;;
|
||||||
-*) urchin_help >&2
|
-*) urchin_help >&2
|
||||||
|
|||||||
Reference in New Issue
Block a user