fix molly guard

This commit is contained in:
Thomas Levine 2016-03-02 21:18:40 +00:00
parent 9fecb802cb
commit 918bf31ec5

88
urchin
View File

@ -445,15 +445,16 @@ validate_strings() {
}
}
cycle_shell=true
shell_list="${urchin_tmp}"/shell_list
run_in_series=false
force=false
exit_on_not_ok=false
tap_format=false
verbose=false
while [ "${#}" -gt 0 ]
do
main() {
cycle_shell=true
shell_list="${urchin_tmp}"/shell_list
run_in_series=false
force=false
exit_on_not_ok=false
tap_format=false
verbose=false
while [ "${#}" -gt 0 ]
do
case "${1}" in
-b|--run-in-series) run_in_series=true;;
-e|--exit-on-fail) exit_on_not_ok=true;;
@ -471,7 +472,7 @@ do
validate_strings "${shell_for_sh_tests}" 'Shell paths'
if echo "${shell_for_sh_tests}" | grep \ > /dev/null; then
echo "Warning: It is best if shell paths contain no spaces so that
you don't need to quote the TEST_SHELL variable." > /dev/stderr
you don't need to quote the TEST_SHELL variable." > /dev/stderr
fi
echo "${shell_for_sh_tests}" >> "${shell_list}"
@ -489,15 +490,16 @@ you don't need to quote the TEST_SHELL variable." > /dev/stderr
*) break;;
esac
shift
done
done
if ! "${cycle_shell}" && test -f "${shell_list}"; then
# -------------------- VALIDATE INPUT -------------------- #
if ! "${cycle_shell}" && test -f "${shell_list}"; then
echo "The -n/--disable-cycling and -s/--shell options clash with each other." >&2
urchin_exit 11
fi
fi
# If -s was not passed, use the available default shells.
if ! test -f "${shell_list}"; then
# If -s was not passed, use the available default shells.
if ! test -f "${shell_list}"; then
if $cycle_shell; then
for shell in $DEFAULT_SHELLS; do
if which $shell > /dev/null; then
@ -507,26 +509,26 @@ if ! test -f "${shell_list}"; then
else
echo > "$shell_list"
fi
fi
fi
# Verify argument for main stuff
if [ "${#}" != '1' ] || [ ! -e "${1}" ]; then
# Verify argument for main stuff
if [ "${#}" != '1' ] || [ ! -e "${1}" ]; then
if [ -n "${1}" ] && [ ! -e "${1}" ]; then
echo "No such file or directory: '${1}'" >&2
fi
echo "${USAGE}" >&2
urchin_exit 11
fi
fi
# Warn about strange sort commands
weird_string='\n- c\n-- b\n--- c\n---- a\n'
if test $(printf "${weird_string}" | sort | tr -d '[ \n-]') != cbca; then
# Warn about strange sort commands
weird_string='\n- c\n-- b\n--- c\n---- a\n'
if test $(printf "${weird_string}" | sort | tr -d '[ \n-]') != cbca; then
echo 'Your version of sort sorts in dictionary order (-d) by default.
Depending on how you name your tests, your Urchin output may look strange.
If this is a problem, install BusyBox or BSD coreutils.' >&2
fi
Depending on how you name your tests, your Urchin output may look strange.
If this is a problem, install BusyBox or BSD coreutils.' >&2
fi
if test -n "${urchin_timeout}"; then
if test -n "${urchin_timeout}"; then
# Choose the timeout command
if timeout -t 0 true; then
TIMEOUT="timeout -t ${urchin_timeout}"
@ -536,18 +538,27 @@ if test -n "${urchin_timeout}"; then
echo I couldn\'t figure out to use your version of timeout >&2
urchin_exit 1
fi
fi
fi
if "${exit_on_not_ok}" && ! "${run_in_series}"; then
if "${exit_on_not_ok}" && ! "${run_in_series}"; then
echo 'You must also pass -b/--series in order to use -e/--exit-on-fail.' >&2
urchin_exit 11
fi
fi
# Run or present the Molly guard.
root="$(urchin_root "${1}")"
if basename "$(fullpath "${root}")" |
grep -i 'test' > /dev/null || "${force}"; then
# Molly guard.
root="$(urchin_root "${1}")"
if ! {
basename "$(fullpath "${root}")" |
grep -i 'test' > /dev/null || "${force}"
}; then
echo 'The root directory of the tests that you are running urchin on
does not contain the word "test", so I am not running,
in case that was an accident. Use the -f flag if you really
want to run urchin on that directory.' >&2
urchin_exit 1
fi
# -------------------- REALLY RUN -------------------- #
start=$(date +%s)
# 1 test file or folder to run
@ -560,11 +571,6 @@ if basename "$(fullpath "${root}")" |
report_outcome "${root}" "${tap_format}" "${urchin_tmp}"/log "${start}" \
"${finish}"
urchin_exit "${?}"
else
echo 'The root directory of the tests that you are running urchin on
does not contain the word "test", so I am not running,
in case that was an accident. Use the -f flag if you really
want to run urchin on that directory.' >&2
exit_code=1
fi
urchin_exit "${exit_code}"
}
main "$@"