Skip to content

Commit 6807d39

Browse files
pks-tgitster
authored andcommitted
t9902: verify that completion does not print anything
The Bash completion script must not print anything to either stdout or stderr. Instead, it is only expected to populate certain variables. Tighten our `test_completion ()` test helper to verify this requirement. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3bf5ccf commit 6807d39

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

t/t9902-completion.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55

66
test_description='test bash completion'
77

8+
# The Bash completion scripts must not print anything to either stdout or
9+
# stderr, which we try to verify. When tracing is enabled without support for
10+
# BASH_XTRACEFD this assertion will fail, so we have to mark the test as
11+
# untraceable with such ancient Bash versions.
12+
test_untraceable=UnfortunatelyYes
13+
814
. ./lib-bash.sh
915

1016
complete ()
@@ -87,9 +93,11 @@ test_completion ()
8793
else
8894
sed -e 's/Z$//' |sort >expected
8995
fi &&
90-
run_completion "$1" &&
96+
run_completion "$1" >"$TRASH_DIRECTORY"/bash-completion-output 2>&1 &&
9197
sort out >out_sorted &&
92-
test_cmp expected out_sorted
98+
test_cmp expected out_sorted &&
99+
test_must_be_empty "$TRASH_DIRECTORY"/bash-completion-output &&
100+
rm "$TRASH_DIRECTORY"/bash-completion-output
93101
}
94102

95103
# Test __gitcomp.

0 commit comments

Comments
 (0)