1
#!/bin/sh
2
3
-test_description='test env--helper'
3
+test_description='test test-tool env-helper'
4
5
TEST_PASSES_SANITIZE_LEAK=true
6
. ./test-lib.sh
7
8
9
-test_expect_success 'env--helper usage' '
10
- test_must_fail git env--helper &&
11
- test_must_fail git env--helper --type=bool &&
12
- test_must_fail git env--helper --type=ulong &&
13
- test_must_fail git env--helper --type=bool &&
14
- test_must_fail git env--helper --type=bool --default &&
15
- test_must_fail git env--helper --type=bool --default= &&
16
- test_must_fail git env--helper --defaultxyz
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
17
'
18
19
-test_expect_success 'env--helper bad default values' '
20
- test_must_fail git env--helper --type=bool --default=1xyz MISSING &&
21
- test_must_fail git env--helper --type=ulong --default=1xyz MISSING
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
22
'
23
24
-test_expect_success 'env--helper --type=bool' '
24
+test_expect_success 'test-tool env-helper --type=bool' '
25
# Test various --default bool values
26
echo true >expected &&
27
- git env--helper --type=bool --default=1 MISSING >actual &&
27
+ test-tool env-helper --type=bool --default=1 MISSING >actual &&
28
test_cmp expected actual &&
29
- git env--helper --type=bool --default=yes MISSING >actual &&
29
+ test-tool env-helper --type=bool --default=yes MISSING >actual &&
30
test_cmp expected actual &&
31
- git env--helper --type=bool --default=true MISSING >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 git env--helper --type=bool --default=0 MISSING >actual &&
34
+ test_must_fail test-tool env-helper --type=bool --default=0 MISSING >actual &&
35
test_cmp expected actual &&
36
- test_must_fail git env--helper --type=bool --default=no MISSING >actual &&
36
+ test_must_fail test-tool env-helper --type=bool --default=no MISSING >actual &&
37
test_cmp expected actual &&
38
- test_must_fail git env--helper --type=bool --default=false MISSING >actual &&
38
+ test_must_fail test-tool env-helper --type=bool --default=false MISSING >actual &&
39
test_cmp expected actual &&
40
41
# No output with --exit-code
42
- git env--helper --type=bool --default=true --exit-code MISSING >actual.out 2>actual.err &&
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 git env--helper --type=bool --default=false --exit-code MISSING >actual.out 2>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 &&
48
49
# Existing variable
50
- EXISTS=true git env--helper --type=bool --default=false --exit-code EXISTS >actual.out 2>actual.err &&
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
- git env--helper --type=bool --default=true --exit-code EXISTS >actual.out 2>actual.err &&
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
58
'
59
60
-test_expect_success 'env--helper --type=ulong' '
60
+test_expect_success 'test-tool env-helper --type=ulong' '
61
echo 1234567890 >expected &&
62
- git env--helper --type=ulong --default=1234567890 MISSING >actual.out 2>actual.err &&
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 &&
65
66
echo 0 >expected &&
67
- test_must_fail git env--helper --type=ulong --default=0 MISSING >actual &&
67
+ test_must_fail test-tool env-helper --type=ulong --default=0 MISSING >actual &&
68
test_cmp expected actual &&
69
70
- git env--helper --type=ulong --default=1234567890 --exit-code MISSING >actual.out 2>actual.err &&
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 &&
73
74
- EXISTS=1234567890 git env--helper --type=ulong --default=0 EXISTS --exit-code >actual.out 2>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 &&
77
78
echo 1234567890 >expected &&
79
- EXISTS=1234567890 git env--helper --type=ulong --default=0 EXISTS >actual.out 2>actual.err &&
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
82
'
83
84
-test_expect_success 'env--helper reads config thanks to trace2' '
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 &&
93
94
test_must_fail \
95
env HOME="$(pwd)/home" GIT_TEST_ENV_HELPER=true \
96
- git -C cycle env--helper --type=bool --default=0 --exit-code GIT_TEST_ENV_HELPER 2>err &&
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
98
'
99