From: Junio C Hamano Date: Tue, 18 Oct 2011 04:37:14 +0000 (-0700) Subject: Merge branch 'jk/config-test-cleanup' X-Git-Tag: v1.7.8-rc0~53 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/0c762702a061c57f1482cc7405989b9373165e40?ds=inline;hp=-c Merge branch 'jk/config-test-cleanup' * jk/config-test-cleanup: t1300: test mixed-case variable retrieval t1300: put git invocations inside test function --- 0c762702a061c57f1482cc7405989b9373165e40 diff --combined t/t1300-repo-config.sh index dffccf84f8,8a37f96396..fba5ae0d18 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@@ -7,28 -7,28 +7,28 @@@ test_description='Test git config in di . ./test-lib.sh - test -f .git/config && rm .git/config - - git config core.penguin "little blue" + test_expect_success 'clear default config' ' + rm -f .git/config + ' cat > expect << EOF [core] penguin = little blue EOF - - test_expect_success 'initial' 'cmp .git/config expect' - - git config Core.Movie BadPhysics + test_expect_success 'initial' ' + git config core.penguin "little blue" && + test_cmp expect .git/config + ' cat > expect << EOF [core] penguin = little blue Movie = BadPhysics EOF - - test_expect_success 'mixed case' 'cmp .git/config expect' - - git config Cores.WhatEver Second + test_expect_success 'mixed case' ' + git config Core.Movie BadPhysics && + test_cmp expect .git/config + ' cat > expect << EOF [core] @@@ -37,10 -37,10 +37,10 @@@ [Cores] WhatEver = Second EOF - - test_expect_success 'similar section' 'cmp .git/config expect' - - git config CORE.UPPERCASE true + test_expect_success 'similar section' ' + git config Cores.WhatEver Second + test_cmp expect .git/config + ' cat > expect << EOF [core] @@@ -50,8 -50,10 +50,10 @@@ [Cores] WhatEver = Second EOF - - test_expect_success 'similar section' 'cmp .git/config expect' + test_expect_success 'uppercase section' ' + git config CORE.UPPERCASE true && + test_cmp expect .git/config + ' test_expect_success 'replace with non-match' \ 'git config core.penguin kingpin !blue' @@@ -69,7 -71,34 +71,34 @@@ cat > expect << EO WhatEver = Second EOF - test_expect_success 'non-match result' 'cmp .git/config expect' + test_expect_success 'non-match result' 'test_cmp expect .git/config' + + test_expect_success 'find mixed-case key by canonical name' ' + echo Second >expect && + git config cores.whatever >actual && + test_cmp expect actual + ' + + test_expect_success 'find mixed-case key by non-canonical name' ' + echo Second >expect && + git config CoReS.WhAtEvEr >actual && + test_cmp expect actual + ' + + test_expect_success 'subsections are not canonicalized by git-config' ' + cat >>.git/config <<-\EOF && + [section.SubSection] + key = one + [section "SubSection"] + key = two + EOF + echo one >expect && + git config section.subsection.key >actual && + test_cmp expect actual && + echo two >expect && + git config section.SubSection.key >actual && + test_cmp expect actual + ' cat > .git/config <<\EOF [alpha] @@@ -88,7 -117,7 +117,7 @@@ bar = fo [beta] EOF - test_expect_success 'unset with cont. lines is correct' 'cmp .git/config expect' + test_expect_success 'unset with cont. lines is correct' 'test_cmp expect .git/config' cat > .git/config << EOF [beta] ; silly comment # another comment @@@ -116,7 -145,7 +145,7 @@@ noIndent= sillyValue ; 'nother silly co [nextSection] noNewline = ouch EOF - test_expect_success 'multiple unset is correct' 'cmp .git/config expect' + test_expect_success 'multiple unset is correct' 'test_cmp expect .git/config' cp .git/config2 .git/config @@@ -140,9 -169,7 +169,7 @@@ noIndent= sillyValue ; 'nother silly co [nextSection] noNewline = ouch EOF - test_expect_success 'all replaced' 'cmp .git/config expect' - - git config beta.haha alpha + test_expect_success 'all replaced' 'test_cmp expect .git/config' cat > expect << EOF [beta] ; silly comment # another comment @@@ -153,10 -180,10 +180,10 @@@ noIndent= sillyValue ; 'nother silly co haha = alpha [nextSection] noNewline = ouch EOF - - test_expect_success 'really mean test' 'cmp .git/config expect' - - git config nextsection.nonewline wow + test_expect_success 'really mean test' ' + git config beta.haha alpha && + test_cmp expect .git/config + ' cat > expect << EOF [beta] ; silly comment # another comment @@@ -168,11 -195,12 +195,12 @@@ noIndent= sillyValue ; 'nother silly co [nextSection] nonewline = wow EOF - - test_expect_success 'really really mean test' 'cmp .git/config expect' + test_expect_success 'really really mean test' ' + git config nextsection.nonewline wow && + test_cmp expect .git/config + ' test_expect_success 'get value' 'test alpha = $(git config beta.haha)' - git config --unset beta.haha cat > expect << EOF [beta] ; silly comment # another comment @@@ -183,10 -211,10 +211,10 @@@ noIndent= sillyValue ; 'nother silly co [nextSection] nonewline = wow EOF - - test_expect_success 'unset' 'cmp .git/config expect' - - git config nextsection.NoNewLine "wow2 for me" "for me$" + test_expect_success 'unset' ' + git config --unset beta.haha && + test_cmp expect .git/config + ' cat > expect << EOF [beta] ; silly comment # another comment @@@ -198,8 -226,10 +226,10 @@@ noIndent= sillyValue ; 'nother silly co nonewline = wow NoNewLine = wow2 for me EOF - - test_expect_success 'multivar' 'cmp .git/config expect' + test_expect_success 'multivar' ' + git config nextsection.NoNewLine "wow2 for me" "for me$" && + test_cmp expect .git/config + ' test_expect_success 'non-match' \ 'git config --get nextsection.nonewline !for' @@@ -214,8 -244,6 +244,6 @@@ test_expect_success 'ambiguous get' test_expect_success 'get multivar' \ 'git config --get-all nextsection.nonewline' - git config nextsection.nonewline "wow3" "wow$" - cat > expect << EOF [beta] ; silly comment # another comment noIndent= sillyValue ; 'nother silly comment @@@ -226,8 -254,10 +254,10 @@@ nonewline = wow3 NoNewLine = wow2 for me EOF - - test_expect_success 'multivar replace' 'cmp .git/config expect' + test_expect_success 'multivar replace' ' + git config nextsection.nonewline "wow3" "wow$" && + test_cmp expect .git/config + ' test_expect_success 'ambiguous value' ' test_must_fail git config nextsection.nonewline @@@ -241,8 -271,6 +271,6 @@@ test_expect_success 'invalid unset' test_must_fail git config --unset somesection.nonewline ' - git config --unset nextsection.nonewline "wow3$" - cat > expect << EOF [beta] ; silly comment # another comment noIndent= sillyValue ; 'nother silly comment @@@ -253,7 -281,10 +281,10 @@@ NoNewLine = wow2 for me EOF - test_expect_success 'multivar unset' 'cmp .git/config expect' + test_expect_success 'multivar unset' ' + git config --unset nextsection.nonewline "wow3$" && + test_cmp expect .git/config + ' test_expect_success 'invalid key' 'test_must_fail git config inval.2key blabla' @@@ -276,7 -307,7 +307,7 @@@ noIndent= sillyValue ; 'nother silly co Alpha = beta EOF - test_expect_success 'hierarchical section value' 'cmp .git/config expect' + test_expect_success 'hierarchical section value' 'test_cmp expect .git/config' cat > expect << EOF beta.noindent=sillyValue @@@ -304,15 -335,16 +335,16 @@@ EO test_expect_success '--get-regexp' \ 'git config --get-regexp in > output && cmp output expect' - git config --add nextsection.nonewline "wow4 for you" - cat > expect << EOF wow2 for me wow4 for you EOF - test_expect_success '--add' \ - 'git config --get-all nextsection.nonewline > output && cmp output expect' + test_expect_success '--add' ' + git config --add nextsection.nonewline "wow4 for you" && + git config --get-all nextsection.nonewline > output && + test_cmp expect output + ' cat > .git/config << EOF [novalue] @@@ -333,12 -365,6 +365,12 @@@ test_expect_success 'get-regexp variabl 'git config --get-regexp novalue > output && cmp output expect' +echo 'novalue.variable true' > expect + +test_expect_success 'get-regexp --bool variable with no value' \ + 'git config --bool --get-regexp novalue > output && + cmp output expect' + echo 'emptyvalue.variable ' > expect test_expect_success 'get-regexp variable with empty value' \ @@@ -367,8 -393,6 +399,6 @@@ cat > .git/config << EO c = d EOF - git config a.x y - cat > expect << EOF [a.b] c = d @@@ -376,10 -400,10 +406,10 @@@ x = y EOF - test_expect_success 'new section is partial match of another' 'cmp .git/config expect' - - git config b.x y - git config a.b c + test_expect_success 'new section is partial match of another' ' + git config a.x y && + test_cmp expect .git/config + ' cat > expect << EOF [a.b] @@@ -391,7 -415,11 +421,11 @@@ x = y EOF - test_expect_success 'new variable inserts into proper section' 'cmp .git/config expect' + test_expect_success 'new variable inserts into proper section' ' + git config b.x y && + git config a.b c && + test_cmp expect .git/config + ' test_expect_success 'alternative GIT_CONFIG (non-existing file should fail)' \ 'test_must_fail git config --file non-existing-config -l' @@@ -405,9 -433,10 +439,10 @@@ cat > expect << EO ein.bahn=strasse EOF - GIT_CONFIG=other-config git config -l > output - - test_expect_success 'alternative GIT_CONFIG' 'cmp output expect' + test_expect_success 'alternative GIT_CONFIG' ' + GIT_CONFIG=other-config git config -l >output && + test_cmp expect output + ' test_expect_success 'alternative GIT_CONFIG (--file)' \ 'git config --file other-config -l > output && cmp output expect' @@@ -423,8 -452,6 +458,6 @@@ test_expect_success 'refer config from ' - GIT_CONFIG=other-config git config anwohner.park ausweis - cat > expect << EOF [ein] bahn = strasse @@@ -432,7 -459,10 +465,10 @@@ park = ausweis EOF - test_expect_success '--set in alternative GIT_CONFIG' 'cmp other-config expect' + test_expect_success '--set in alternative GIT_CONFIG' ' + GIT_CONFIG=other-config git config anwohner.park ausweis && + test_cmp expect other-config + ' cat > .git/config << EOF # Hallo @@@ -537,7 -567,7 +573,7 @@@ test_expect_success 'section ending' git config gitcvs.enabled true && git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite && git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite && - cmp .git/config expect + test_cmp expect .git/config ' @@@ -756,13 -786,6 +792,6 @@@ test_expect_success NOT_MINGW 'get --pa test_cmp expect result ' - rm .git/config - - git config quote.leading " test" - git config quote.ending "test " - git config quote.semicolon "test;test" - git config quote.hash "test#test" - cat > expect << EOF [quote] leading = " test" @@@ -770,8 -793,14 +799,14 @@@ semicolon = "test;test" hash = "test#test" EOF - - test_expect_success 'quoting' 'cmp .git/config expect' + test_expect_success 'quoting' ' + rm .git/config && + git config quote.leading " test" && + git config quote.ending "test " && + git config quote.semicolon "test;test" && + git config quote.hash "test#test" && + test_cmp expect .git/config + ' test_expect_success 'key with newline' ' test_must_fail git config "key.with @@@ -796,9 -825,10 +831,10 @@@ section.noncont=not continue section.quotecont=cont;inued EOF - git config --list > result - - test_expect_success 'value continued on next line' 'cmp result expect' + test_expect_success 'value continued on next line' ' + git config --list > result && + cmp result expect + ' cat > .git/config <<\EOF [section "sub=section"] @@@ -819,16 -849,17 +855,17 @@@ barQsection.sub=section.val Qsection.sub=section.val4 Qsection.sub=section.val5Q EOF + test_expect_success '--null --list' ' + git config --null --list | nul_to_q >result && + echo >>result && + test_cmp expect result + ' - git config --null --list | perl -pe 'y/\000/Q/' > result - echo >>result - - test_expect_success '--null --list' 'cmp result expect' - - git config --null --get-regexp 'val[0-9]' | perl -pe 'y/\000/Q/' > result - echo >>result - - test_expect_success '--null --get-regexp' 'cmp result expect' + test_expect_success '--null --get-regexp' ' + git config --null --get-regexp "val[0-9]" | nul_to_q >result && + echo >>result && + test_cmp expect result + ' test_expect_success 'inner whitespace kept verbatim' ' git config section.val "foo bar" &&