Skip to content

Commit e4c0a14

Browse files
peffgitster
authored andcommitted
t0012: optionally check that "-h" output goes to stdout
For most commands, "git foo -h" will send the help output to stdout, as this is what parse-options.c does. But some commands send it to stderr instead. This is usually because they call usage_with_options(), and should be switched to show_usage_help_and_exit_if_asked(). Currently t0012 is permissive and allows either behavior. We'd like it to eventually enforce that help goes to stdout, and teaching it to do so identifies the commands that need to be changed. But during the transition period, we don't want to enforce that for most test runs. So let's introduce a flag that will let most test runs use the permissive behavior, and people interested in converting commands can run: GIT_TEST_HELP_MUST_BE_STDOUT=1 ./t0012-help.sh to see the failures. Eventually (when all builtins have been converted) we'll remove this flag entirely and always check the strict behavior. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fbe8d30 commit e4c0a14

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

t/t0012-help.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,16 @@ do
255255
(
256256
GIT_CEILING_DIRECTORIES=$(pwd) &&
257257
export GIT_CEILING_DIRECTORIES &&
258-
test_expect_code 129 git -C sub $builtin -h >output 2>&1
258+
test_expect_code 129 git -C sub $builtin -h >output 2>err
259259
) &&
260-
test_grep usage output
260+
if test -n "$GIT_TEST_HELP_MUST_BE_STDOUT"
261+
then
262+
test_must_be_empty err &&
263+
test_grep usage output
264+
else
265+
test_grep usage output ||
266+
test_grep usage err
267+
fi
261268
'
262269
done <builtins
263270

0 commit comments

Comments
 (0)