File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,8 @@ _STUB_RESULT="${PROGRAM}_STUB_RESULT"
1414_STUB_END=" ${PROGRAM} _STUB_END"
1515_STUB_DEBUG=" ${PROGRAM} _STUB_DEBUG"
1616
17- if [ -n " ${! _STUB_DEBUG} " ]; then
18- echo " $program " " $@ " >& ${! _STUB_DEBUG}
17+ if [ -n " ${! _STUB_DEBUG} " ] && [ -z " ${ ! _STUB_END} " ] ; then
18+ echo stub: " $program " " $@ " >& ${! _STUB_DEBUG}
1919fi
2020
2121[ -e " ${! _STUB_PLAN} " ] || exit 1
2525# Initialize or load the stub run information.
2626eval " ${_STUB_INDEX} " =1
2727eval " ${_STUB_RESULT} " =0
28+ # shellcheck disable=SC1090
2829[ ! -e " ${! _STUB_RUN} " ] || source " ${! _STUB_RUN} "
2930
3031# Expose this for stub scripts.
32+ # shellcheck disable=SC2317
3133inspect_args () {
3234 local arg
3335 local sep=' '
@@ -101,9 +103,11 @@ if [ -n "${!_STUB_END}" ]; then
101103 # Clean up the run file.
102104 rm -f " ${! _STUB_RUN} "
103105
106+ stub_index_value=" ${! _STUB_INDEX} "
104107 # If the number of lines in the plan is larger than
105108 # the requested index, we failed.
106- if [ $index -ge " ${! _STUB_INDEX} " ]; then
109+ if [ " $index " -ge " $stub_index_value " ]; then
110+ echo " $program : expected $index invocations, got $(( stub_index_value- 1 )) " >&2
107111 eval " ${_STUB_RESULT} " =1
108112 fi
109113
Original file line number Diff line number Diff line change @@ -66,9 +66,17 @@ unstub() {
6666
6767 export " ${prefix} _STUB_END" =1
6868
69+ local stub_was_invoked=
70+ [ -e " ${TMP} /${program} -stub-run" ] && stub_was_invoked=1
71+
6972 local STATUS=0
7073 " $path " || STATUS=" $? "
7174
75+ local debug_var=" ${prefix} _STUB_DEBUG"
76+ if [ $STATUS -ne 0 ] && [ -z " ${! debug_var} " ] && [ -n " $stub_was_invoked " ]; then
77+ echo " unstub $program : re-run test with ${debug_var} =3 to log \` $program ' invocations" >&2
78+ fi
79+
7280 rm -f " $path "
7381 rm -f " ${TMP} /${program} -stub-plan" " ${TMP} /${program} -stub-run"
7482 return " $STATUS "
You can’t perform that action at this time.
0 commit comments