mirror of
https://github.com/pyenv/pyenv.git
synced 2024-12-22 23:20:47 +00:00
Bats: report unstub failure details
This commit is contained in:
parent
c6c4e41eb9
commit
6882be06a6
2 changed files with 33 additions and 8 deletions
|
@ -11,11 +11,10 @@ _STUB_RUN="${PROGRAM}_STUB_RUN"
|
|||
_STUB_INDEX="${PROGRAM}_STUB_INDEX"
|
||||
_STUB_RESULT="${PROGRAM}_STUB_RESULT"
|
||||
_STUB_END="${PROGRAM}_STUB_END"
|
||||
_STUB_DEBUG="${PROGRAM}_STUB_DEBUG"
|
||||
_STUB_LOG="${PROGRAM}_STUB_LOG"
|
||||
|
||||
if [ -n "${!_STUB_DEBUG}" ]; then
|
||||
echo "$program" "$@" >&${!_STUB_DEBUG}
|
||||
fi
|
||||
[ -n "${!_STUB_LOG}" ] || eval "${_STUB_LOG}"="${TMPDIR}/${program}-stub-log"
|
||||
if test -z "${!_STUB_END}"; then echo "$program" "$@" >>"${!_STUB_LOG}"; fi
|
||||
|
||||
[ -e "${!_STUB_PLAN}" ] || exit 1
|
||||
[ -n "${!_STUB_RUN}" ] || eval "${_STUB_RUN}"="${TMPDIR}/${program}-stub-run"
|
||||
|
@ -24,7 +23,7 @@ fi
|
|||
# Initialize or load the stub run information.
|
||||
eval "${_STUB_INDEX}"=1
|
||||
eval "${_STUB_RESULT}"=0
|
||||
[ ! -e "${!_STUB_RUN}" ] || source "${!_STUB_RUN}"
|
||||
if test -e "${!_STUB_RUN}"; then source "${!_STUB_RUN}"; fi
|
||||
|
||||
|
||||
# Loop over each line in the plan.
|
||||
|
@ -80,14 +79,39 @@ done < "${!_STUB_PLAN}"
|
|||
|
||||
|
||||
if [ -n "${!_STUB_END}" ]; then
|
||||
# Clean up the run file.
|
||||
rm -f "${!_STUB_RUN}"
|
||||
|
||||
# If the number of lines in the plan is larger than
|
||||
# the requested index, we failed.
|
||||
if [ $index -ge "${!_STUB_INDEX}" ]; then
|
||||
eval "${_STUB_RESULT}"=1
|
||||
{
|
||||
echo "index: $index; stub index: ${!_STUB_INDEX}"
|
||||
echo "plan:"
|
||||
cat "${!_STUB_PLAN}"
|
||||
echo "run:"
|
||||
cat "${!_STUB_RUN}"
|
||||
echo "log:"
|
||||
cat "${!_STUB_LOG}"
|
||||
} >&2
|
||||
fi
|
||||
if [ "${!_STUB_RESULT}" -ne 0 ]; then
|
||||
{
|
||||
echo "index: $index; stub index: ${!_STUB_INDEX}"
|
||||
echo "plan:"
|
||||
cat "${!_STUB_PLAN}" || true
|
||||
echo "run:"
|
||||
cat "${!_STUB_RUN}" || true
|
||||
echo "log:"
|
||||
cat "${!_STUB_LOG}" || true
|
||||
} >&2
|
||||
fi
|
||||
|
||||
# Clean up the run file.
|
||||
rm -f "${!_STUB_RUN}"
|
||||
rm -f "${!_STUB_LOG}"
|
||||
|
||||
# Clean up the run file.
|
||||
rm -f "${!_STUB_RUN}"
|
||||
rm -f "${!_STUB_LOG}"
|
||||
|
||||
# Return the result.
|
||||
exit "${!_STUB_RESULT}"
|
||||
|
|
|
@ -25,6 +25,7 @@ stub() {
|
|||
|
||||
export "${prefix}_STUB_PLAN"="${TMP}/${program}-stub-plan"
|
||||
export "${prefix}_STUB_RUN"="${TMP}/${program}-stub-run"
|
||||
export "${prefix}_STUB_LOG"="${TMP}/${program}-stub-log"
|
||||
export "${prefix}_STUB_END"=
|
||||
|
||||
mkdir -p "${TMP}/bin"
|
||||
|
|
Loading…
Reference in a new issue