Skip to content

Commit 3ff999e

Browse files
committed
Merge branch 'zj/test-cred-helper-nicer-prove'
Minor improvement to t0303. By Zbigniew Jędrzejewski-Szmek * zj/test-cred-helper-nicer-prove: t0303: resurrect commit message as test documentation t0303: immediately bail out w/o GIT_TEST_CREDENTIAL_HELPER
2 parents 4e52008 + 6c556cb commit 3ff999e

File tree

1 file changed

+45
-24
lines changed

1 file changed

+45
-24
lines changed

t/t0303-credential-external.sh

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,60 @@
11
#!/bin/sh
22

3-
test_description='external credential helper tests'
4-
. ./test-lib.sh
5-
. "$TEST_DIRECTORY"/lib-credential.sh
3+
test_description='external credential helper tests
64
7-
pre_test() {
8-
test -z "$GIT_TEST_CREDENTIAL_HELPER_SETUP" ||
9-
eval "$GIT_TEST_CREDENTIAL_HELPER_SETUP"
5+
This is a tool for authors of external helper tools to sanity-check
6+
their helpers. If you have written the "git-credential-foo" helper,
7+
you check it with:
8+
9+
make GIT_TEST_CREDENTIAL_HELPER=foo t0303-credential-external.sh
10+
11+
This assumes that your helper is capable of both storing and
12+
retrieving credentials (some helpers may be read-only, and they will
13+
fail these tests).
14+
15+
Please note that the individual tests do not verify all of the
16+
preconditions themselves, but rather build on each other. A failing
17+
test means that tests later in the sequence can return false "OK"
18+
results.
19+
20+
If your helper supports time-based expiration with a configurable
21+
timeout, you can test that feature with:
22+
23+
make GIT_TEST_CREDENTIAL_HELPER=foo \
24+
GIT_TEST_CREDENTIAL_HELPER_TIMEOUT="foo --timeout=1" \
25+
t0303-credential-external.sh
1026
11-
# clean before the test in case there is cruft left
12-
# over from a previous run that would impact results
13-
helper_test_clean "$GIT_TEST_CREDENTIAL_HELPER"
14-
}
27+
If your helper requires additional setup before the tests are started,
28+
you can set GIT_TEST_CREDENTIAL_HELPER_SETUP to a sequence of shell
29+
commands.
30+
'
1531

16-
post_test() {
17-
# clean afterwards so that we are good citizens
18-
# and don't leave cruft in the helper's storage, which
19-
# might be long-term system storage
20-
helper_test_clean "$GIT_TEST_CREDENTIAL_HELPER"
21-
}
32+
. ./test-lib.sh
33+
. "$TEST_DIRECTORY"/lib-credential.sh
2234

2335
if test -z "$GIT_TEST_CREDENTIAL_HELPER"; then
24-
say "# skipping external helper tests (set GIT_TEST_CREDENTIAL_HELPER)"
25-
else
26-
pre_test
27-
helper_test "$GIT_TEST_CREDENTIAL_HELPER"
28-
post_test
36+
skip_all="used to test external credential helpers"
37+
test_done
2938
fi
3039

40+
test -z "$GIT_TEST_CREDENTIAL_HELPER_SETUP" ||
41+
eval "$GIT_TEST_CREDENTIAL_HELPER_SETUP"
42+
43+
# clean before the test in case there is cruft left
44+
# over from a previous run that would impact results
45+
helper_test_clean "$GIT_TEST_CREDENTIAL_HELPER"
46+
47+
helper_test "$GIT_TEST_CREDENTIAL_HELPER"
48+
3149
if test -z "$GIT_TEST_CREDENTIAL_HELPER_TIMEOUT"; then
32-
say "# skipping external helper timeout tests"
50+
say "# skipping timeout tests (GIT_TEST_CREDENTIAL_HELPER_TIMEOUT not set)"
3351
else
34-
pre_test
3552
helper_test_timeout "$GIT_TEST_CREDENTIAL_HELPER_TIMEOUT"
36-
post_test
3753
fi
3854

55+
# clean afterwards so that we are good citizens
56+
# and don't leave cruft in the helper's storage, which
57+
# might be long-term system storage
58+
helper_test_clean "$GIT_TEST_CREDENTIAL_HELPER"
59+
3960
test_done

0 commit comments

Comments
 (0)