Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t0017-env-helper.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t0017-env-helper.sh` 106 lines ยท 4052 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='test test-tool env-helper' 4 5 . ./test-lib.sh 6 7 8 test_expect_success 'test-tool env-helper usage' ' 9 test_must_fail test-tool env-helper && 10 test_must_fail test-tool env-helper --type=bool && 11 test_must_fail test-tool env-helper --type=ulong && 12 test_must_fail test-tool env-helper --type=bool && 13 test_must_fail test-tool env-helper --type=bool --default && 14 test_must_fail test-tool env-helper --type=bool --default= && 15 test_must_fail test-tool env-helper --defaultxyz 16 ' 17 18 test_expect_success 'test-tool env-helper bad default values' ' 19 test_must_fail test-tool env-helper --type=bool --default=1xyz MISSING && 20 test_must_fail test-tool env-helper --type=ulong --default=1xyz MISSING 21 ' 22 23 test_expect_success 'test-tool env-helper --type=bool' ' 24 # Test various --default bool values 25 echo true >expected && 26 test-tool env-helper --type=bool --default=1 MISSING >actual && 27 test_cmp expected actual && 28 test-tool env-helper --type=bool --default=yes MISSING >actual && 29 test_cmp expected actual && 30 test-tool env-helper --type=bool --default=true MISSING >actual && 31 test_cmp expected actual && 32 echo false >expected && 33 test_must_fail test-tool env-helper --type=bool --default=0 MISSING >actual && 34 test_cmp expected actual && 35 test_must_fail test-tool env-helper --type=bool --default=no MISSING >actual && 36 test_cmp expected actual && 37 test_must_fail test-tool env-helper --type=bool --default=false MISSING >actual && 38 test_cmp expected actual && 39 40 # No output with --exit-code 41 test-tool env-helper --type=bool --default=true --exit-code MISSING >actual.out 2>actual.err && 42 test_must_be_empty actual.out && 43 test_must_be_empty actual.err && 44 test_must_fail test-tool env-helper --type=bool --default=false --exit-code MISSING >actual.out 2>actual.err && 45 test_must_be_empty actual.out && 46 test_must_be_empty actual.err && 47 48 # Existing variable 49 EXISTS=true test-tool env-helper --type=bool --default=false --exit-code EXISTS >actual.out 2>actual.err && 50 test_must_be_empty actual.out && 51 test_must_be_empty actual.err && 52 test_must_fail \ 53 env EXISTS=false \ 54 test-tool env-helper --type=bool --default=true --exit-code EXISTS >actual.out 2>actual.err && 55 test_must_be_empty actual.out && 56 test_must_be_empty actual.err 57 ' 58 59 test_expect_success 'test-tool env-helper --type=ulong' ' 60 echo `1234567890` >expected && 61 test-tool env-helper --type=ulong --default=`1234567890` MISSING >actual.out 2>actual.err && 62 test_cmp expected actual.out && 63 test_must_be_empty actual.err && 64 65 echo 0 >expected && 66 test_must_fail test-tool env-helper --type=ulong --default=0 MISSING >actual && 67 test_cmp expected actual && 68 69 test-tool env-helper --type=ulong --default=`1234567890` --exit-code MISSING >actual.out 2>actual.err && 70 test_must_be_empty actual.out && 71 test_must_be_empty actual.err && 72 73 EXISTS=`1234567890` test-tool env-helper --type=ulong --default=0 EXISTS --exit-code >actual.out 2>actual.err && 74 test_must_be_empty actual.out && 75 test_must_be_empty actual.err && 76 77 echo `1234567890` >expected && 78 EXISTS=`1234567890` test-tool env-helper --type=ulong --default=0 EXISTS >actual.out 2>actual.err && 79 test_cmp expected actual.out && 80 test_must_be_empty actual.err 81 ' 82 83 test_expect_success 'test-tool env-helper reads config thanks to trace2' ' 84 mkdir home && 85 git config -f home/.gitconfig include.path cycle && 86 git config -f home/cycle include.path .gitconfig && 87 88 test_must_fail \ 89 env HOME="$(pwd)/home" \ 90 git config -l 2>err && 91 test_grep "exceeded maximum include depth" err && 92 93 # This validates that the assumption that we attempt to 94 # read the configuration and fail very early in the start-up 95 # sequence (due to trace2 subsystem), even before we notice 96 # that the directory named with "test-tool -C" does not exist 97 # and die. It is a dubious thing to test, though. 98 test_must_fail \ 99 env HOME="$(pwd)/home" GIT_TEST_ENV_HELPER=true \ 100 test-tool -C no-such-directory \ 101 env-helper --type=bool --default=0 \ 102 --exit-code GIT_TEST_ENV_HELPER 2>err && 103 test_grep "exceeded maximum include depth" err 104 ' 105 106 test_done