Re: [PATCH] Test the interaction of --bool and --get-regexp on a key with no explicit value
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Aug 27, 2010, 03:15 UTC
- Message-ID
- <20100827031511.GC23924@burratino>
- In-Reply-To
- <1282844716-30591-1-git-send-email-alex@chmrr.net>
Alex Vandiver wrote:
Show 8 quoted lines
> Signed-off-by: Alex Vandiver <alex@chmrr.net> > --- > > This test currently fails -- I don't have time to track down the fix, > but I figured that at least I could provide a failing test. Note that > --null isn't necessary for the failure; without it, one gets > "section.sub=section.val5true", with no spacing between the key and > value.
This is useful info (the motivation!) for the log mesage I think, though it might be even better to squash the patch with the fix. :)
Show 15 quoted lines
> --- a/t/t1300-repo-config.sh > +++ b/t/t1300-repo-config.sh > @@ -816,6 +816,16 @@ echo >>result > > test_expect_success '--null --get-regexp' 'cmp result expect' > > +cat > expect <<\EOF > +section.sub=section.val5 > +trueQ > +EOF > + > +git config --null --bool --get-regexp 'val5' | perl -pe 'y/\000/Q/' > result > +echo >>result > + > +test_expect_success '--null --get-regexp --bool' 'cmp result expect'
Style nitpicks (based on the "Do's, don'ts &" c section of t/README):
- setup code (cat >expect) belongs in the body of tests. That way, it is clearer when each test begins and ends, and unexpected failures and output from setup code will be automatically noticed and suppressed, respectively.
- there is no public nul_to_q () function but I still think it is clearer to use one;
- test_cmp is guaranteed to work just as well as cmp and produces nicer output when tests run with "-v" fail.
So maybe:
test_expect_failure '--get-regexp --bool still separates key and value' ' echo 'section.sub=section.val5 true' >expected && git config --bool --get-regexp val5 >actual && test_cmp expected acutal '
test_expect_failure '--get-regexp --bool --null' ' printf "%s\n%s\0" "section.sub=section.val5" "true" >expected && git config -z --bool --get-regexp val5 >actual && test_cmp expected actual '
Thanks for reporting.