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