]> git.ipfire.org Git - thirdparty/git.git/blame - t/t0017-env-helper.sh
The third batch
[thirdparty/git.git] / t / t0017-env-helper.sh
CommitLineData
b4f207f3
ÆAB
1#!/bin/sh
2
4a1baacd 3test_description='test test-tool env-helper'
b4f207f3 4
956d2e46 5TEST_PASSES_SANITIZE_LEAK=true
b4f207f3
ÆAB
6. ./test-lib.sh
7
8
4a1baacd
ÆAB
9test_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
b4f207f3
ÆAB
17'
18
4a1baacd
ÆAB
19test_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
b4f207f3
ÆAB
22'
23
4a1baacd 24test_expect_success 'test-tool env-helper --type=bool' '
b4f207f3
ÆAB
25 # Test various --default bool values
26 echo true >expected &&
4a1baacd 27 test-tool env-helper --type=bool --default=1 MISSING >actual &&
b4f207f3 28 test_cmp expected actual &&
4a1baacd 29 test-tool env-helper --type=bool --default=yes MISSING >actual &&
b4f207f3 30 test_cmp expected actual &&
4a1baacd 31 test-tool env-helper --type=bool --default=true MISSING >actual &&
b4f207f3
ÆAB
32 test_cmp expected actual &&
33 echo false >expected &&
4a1baacd 34 test_must_fail test-tool env-helper --type=bool --default=0 MISSING >actual &&
b4f207f3 35 test_cmp expected actual &&
4a1baacd 36 test_must_fail test-tool env-helper --type=bool --default=no MISSING >actual &&
b4f207f3 37 test_cmp expected actual &&
4a1baacd 38 test_must_fail test-tool env-helper --type=bool --default=false MISSING >actual &&
b4f207f3
ÆAB
39 test_cmp expected actual &&
40
41 # No output with --exit-code
4a1baacd 42 test-tool env-helper --type=bool --default=true --exit-code MISSING >actual.out 2>actual.err &&
b4f207f3
ÆAB
43 test_must_be_empty actual.out &&
44 test_must_be_empty actual.err &&
4a1baacd 45 test_must_fail test-tool env-helper --type=bool --default=false --exit-code MISSING >actual.out 2>actual.err &&
b4f207f3
ÆAB
46 test_must_be_empty actual.out &&
47 test_must_be_empty actual.err &&
48
49 # Existing variable
4a1baacd 50 EXISTS=true test-tool env-helper --type=bool --default=false --exit-code EXISTS >actual.out 2>actual.err &&
b4f207f3
ÆAB
51 test_must_be_empty actual.out &&
52 test_must_be_empty actual.err &&
53 test_must_fail \
54 env EXISTS=false \
4a1baacd 55 test-tool env-helper --type=bool --default=true --exit-code EXISTS >actual.out 2>actual.err &&
b4f207f3
ÆAB
56 test_must_be_empty actual.out &&
57 test_must_be_empty actual.err
58'
59
4a1baacd 60test_expect_success 'test-tool env-helper --type=ulong' '
b4f207f3 61 echo 1234567890 >expected &&
4a1baacd 62 test-tool env-helper --type=ulong --default=1234567890 MISSING >actual.out 2>actual.err &&
b4f207f3
ÆAB
63 test_cmp expected actual.out &&
64 test_must_be_empty actual.err &&
65
66 echo 0 >expected &&
4a1baacd 67 test_must_fail test-tool env-helper --type=ulong --default=0 MISSING >actual &&
b4f207f3
ÆAB
68 test_cmp expected actual &&
69
4a1baacd 70 test-tool env-helper --type=ulong --default=1234567890 --exit-code MISSING >actual.out 2>actual.err &&
b4f207f3
ÆAB
71 test_must_be_empty actual.out &&
72 test_must_be_empty actual.err &&
73
4a1baacd 74 EXISTS=1234567890 test-tool env-helper --type=ulong --default=0 EXISTS --exit-code >actual.out 2>actual.err &&
b4f207f3
ÆAB
75 test_must_be_empty actual.out &&
76 test_must_be_empty actual.err &&
77
78 echo 1234567890 >expected &&
4a1baacd 79 EXISTS=1234567890 test-tool env-helper --type=ulong --default=0 EXISTS >actual.out 2>actual.err &&
b4f207f3
ÆAB
80 test_cmp expected actual.out &&
81 test_must_be_empty actual.err
82'
83
4a1baacd 84test_expect_success 'test-tool env-helper reads config thanks to trace2' '
1ff750b1
ÆAB
85 mkdir home &&
86 git config -f home/.gitconfig include.path cycle &&
87 git config -f home/cycle include.path .gitconfig &&
88
89 test_must_fail \
d162b25f 90 env HOME="$(pwd)/home" \
1ff750b1
ÆAB
91 git config -l 2>err &&
92 grep "exceeded maximum include depth" err &&
93
94 test_must_fail \
d162b25f 95 env HOME="$(pwd)/home" GIT_TEST_ENV_HELPER=true \
4a1baacd 96 test-tool -C cycle env-helper --type=bool --default=0 --exit-code GIT_TEST_ENV_HELPER 2>err &&
d162b25f 97 grep "exceeded maximum include depth" err
1ff750b1
ÆAB
98'
99
b4f207f3 100test_done