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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Jan 15, 2024 at 11:36 UTC
6807d3942c6104b32f6c7e04c1f7b5d2c82afa30
1 file changed
+10
-2
t/t9902-completion.sh
+10
-2
@@ -5,6 +5,12 @@
5
6
test_description='test bash completion'
7
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
+
14
. ./lib-bash.sh
15
16
complete ()
@@ -87,9 +93,11 @@ test_completion ()
93
else
94
sed -e 's/Z$//' |sort >expected
95
fi &&
90
- run_completion "$1" &&
96
+ run_completion "$1" >"$TRASH_DIRECTORY"/bash-completion-output 2>&1 &&
97
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
101
}
102
103
# Test __gitcomp.