t7800: improve test descriptions with empty arguments
[alt-git.git] / t / t0017-env-helper.sh
blobfc14ba091cb247e5fc7395b0b89f615e43193c85
1 #!/bin/sh
3 test_description='test test-tool env-helper'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
9 test_expect_success 'test-tool env-helper usage' '
10 test_must_fail test-tool env-helper &&
11 test_must_fail test-tool env-helper --type=bool &&
12 test_must_fail test-tool env-helper --type=ulong &&
13 test_must_fail test-tool env-helper --type=bool &&
14 test_must_fail test-tool env-helper --type=bool --default &&
15 test_must_fail test-tool env-helper --type=bool --default= &&
16 test_must_fail test-tool env-helper --defaultxyz
19 test_expect_success 'test-tool env-helper bad default values' '
20 test_must_fail test-tool env-helper --type=bool --default=1xyz MISSING &&
21 test_must_fail test-tool env-helper --type=ulong --default=1xyz MISSING
24 test_expect_success 'test-tool env-helper --type=bool' '
25 # Test various --default bool values
26 echo true >expected &&
27 test-tool env-helper --type=bool --default=1 MISSING >actual &&
28 test_cmp expected actual &&
29 test-tool env-helper --type=bool --default=yes MISSING >actual &&
30 test_cmp expected actual &&
31 test-tool env-helper --type=bool --default=true MISSING >actual &&
32 test_cmp expected actual &&
33 echo false >expected &&
34 test_must_fail test-tool env-helper --type=bool --default=0 MISSING >actual &&
35 test_cmp expected actual &&
36 test_must_fail test-tool env-helper --type=bool --default=no MISSING >actual &&
37 test_cmp expected actual &&
38 test_must_fail test-tool env-helper --type=bool --default=false MISSING >actual &&
39 test_cmp expected actual &&
41 # No output with --exit-code
42 test-tool env-helper --type=bool --default=true --exit-code MISSING >actual.out 2>actual.err &&
43 test_must_be_empty actual.out &&
44 test_must_be_empty actual.err &&
45 test_must_fail test-tool env-helper --type=bool --default=false --exit-code MISSING >actual.out 2>actual.err &&
46 test_must_be_empty actual.out &&
47 test_must_be_empty actual.err &&
49 # Existing variable
50 EXISTS=true test-tool env-helper --type=bool --default=false --exit-code EXISTS >actual.out 2>actual.err &&
51 test_must_be_empty actual.out &&
52 test_must_be_empty actual.err &&
53 test_must_fail \
54 env EXISTS=false \
55 test-tool env-helper --type=bool --default=true --exit-code EXISTS >actual.out 2>actual.err &&
56 test_must_be_empty actual.out &&
57 test_must_be_empty actual.err
60 test_expect_success 'test-tool env-helper --type=ulong' '
61 echo 1234567890 >expected &&
62 test-tool env-helper --type=ulong --default=1234567890 MISSING >actual.out 2>actual.err &&
63 test_cmp expected actual.out &&
64 test_must_be_empty actual.err &&
66 echo 0 >expected &&
67 test_must_fail test-tool env-helper --type=ulong --default=0 MISSING >actual &&
68 test_cmp expected actual &&
70 test-tool env-helper --type=ulong --default=1234567890 --exit-code MISSING >actual.out 2>actual.err &&
71 test_must_be_empty actual.out &&
72 test_must_be_empty actual.err &&
74 EXISTS=1234567890 test-tool env-helper --type=ulong --default=0 EXISTS --exit-code >actual.out 2>actual.err &&
75 test_must_be_empty actual.out &&
76 test_must_be_empty actual.err &&
78 echo 1234567890 >expected &&
79 EXISTS=1234567890 test-tool env-helper --type=ulong --default=0 EXISTS >actual.out 2>actual.err &&
80 test_cmp expected actual.out &&
81 test_must_be_empty actual.err
84 test_expect_success 'test-tool env-helper reads config thanks to trace2' '
85 mkdir home &&
86 git config -f home/.gitconfig include.path cycle &&
87 git config -f home/cycle include.path .gitconfig &&
89 test_must_fail \
90 env HOME="$(pwd)/home" \
91 git config -l 2>err &&
92 grep "exceeded maximum include depth" err &&
94 test_must_fail \
95 env HOME="$(pwd)/home" GIT_TEST_ENV_HELPER=true \
96 test-tool -C cycle env-helper --type=bool --default=0 --exit-code GIT_TEST_ENV_HELPER 2>err &&
97 grep "exceeded maximum include depth" err
100 test_done