Skip to content

Commit a88dbd2

Browse files
peffjrn
authored andcommitted
t0300: make "quit" helper more realistic
We test a toy credential helper that writes "quit=1" and confirms that we stop running other helpers. However, that helper is unrealistic in that it does not bother to read its stdin at all. For now we don't send any input to it, because we feed git-credential a blank credential. But that will change in the next patch, which will cause this test to racily fail, as git-credential will get SIGPIPE writing to the helper rather than exiting because it was asked to. Let's make this one-off helper more like our other sample helpers, and have it source the "dump" script. That will read stdin, fixing the SIGPIPE problem. But it will also write what it sees to stderr. We can make the test more robust by checking that output, which confirms that we do run the quit helper, don't run any other helpers, and exit for the reason we expected. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]>
1 parent c42c0f1 commit a88dbd2

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

t/t0300-credentials.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ test_expect_success 'setup helper scripts' '
2222
exit 0
2323
EOF
2424
25+
write_script git-credential-quit <<-\EOF &&
26+
. ./dump
27+
echo quit=1
28+
EOF
29+
2530
write_script git-credential-verbatim <<-\EOF &&
2631
user=$1; shift
2732
pass=$1; shift
@@ -291,11 +296,16 @@ test_expect_success 'http paths can be part of context' '
291296

292297
test_expect_success 'helpers can abort the process' '
293298
test_must_fail git \
294-
-c credential.helper="!f() { echo quit=1; }; f" \
299+
-c credential.helper=quit \
295300
-c credential.helper="verbatim foo bar" \
296-
credential fill >stdout &&
301+
credential fill >stdout 2>stderr &&
297302
>expect &&
298-
test_cmp expect stdout
303+
test_cmp expect stdout &&
304+
cat >expect <<-\EOF &&
305+
quit: get
306+
fatal: credential helper '\''quit'\'' told us to quit
307+
EOF
308+
test_i18ncmp expect stderr
299309
'
300310

301311
test_expect_success 'empty helper spec resets helper list' '

0 commit comments

Comments
 (0)