Improve test output for failed stubs #2498
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
stub
/unstub
test helpers are unfortunately opaque as both are undocumented, and when stubbing fails for some reason, determining why is left as a guessing/debugging exercise. This was a time-sink for myself on many an occasion.This improves the
unstub <PROGRAM>
helper output with the following features:If the number of PROGRAM invocations was fewer than the number of stubbed (i.e. expected) arguments, it now prints
expected X invocations, got Y
to stderr;If PROGRAM got invoked but
unstub PROGRAM
still failed, it was likely that some of the invocations didn't match the stubbed ones. However, the human reading the test output has no insight into which invocations actually happened. The unstub helper now prints:This "debug" mode already existed, but is off by default, and could previously only be discovered by someone who read the
stub
implementation code. After following the new suggestion, actual invocations of PROGRAM and all its arguments will be printed to stderr during the test run, hopefully making it clearer for the human debugging the test.