From: Eric Sunshine Date: Tue, 03 Sep 2013 08:16:46 GMT Subject: Re: [PATCH v3 8/8] update-ref: add test cases covering --stdin signature Message-ID: In-Reply-To: <9457f5c046a0fb420f4fd730c7b02c2a75ee7e0d.1378142796.git.brad.king@kitware.com> On Mon, Sep 2, 2013 at 1:48 PM, Brad King wrote: > Extend t/t1400-update-ref.sh to cover cases using the --stdin option. > > Signed-off-by: Brad King > --- > t/t1400-update-ref.sh | 256 +++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 256 insertions(+) > > diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh > index e415ee0..b6d7dfa 100755 > --- a/t/t1400-update-ref.sh > +++ b/t/t1400-update-ref.sh > @@ -302,4 +302,260 @@ test_expect_success \ > 'git cat-file blob master@{2005-05-26 23:42}:F (expect OTHER)' \ > 'test OTHER = $(git cat-file blob "master@{2005-05-26 23:42}:F")' > > +a=refs/heads/a > +b=refs/heads/b > +c=refs/heads/c > +z=0000000000000000000000000000000000000000 > +e='""' > +pws='path with space' > + > +test_expect_success 'stdin fails on bad input line with only whitespace' ' > + echo " " >stdin && > + test_must_fail git update-ref --stdin err && > + grep "fatal: no ref on line: " err > +' > + > +test_expect_success 'stdin fails on bad input line with only --' ' > + echo "--" >stdin && > + test_must_fail git update-ref --stdin err && > + grep "fatal: no ref on line: --" err > +' > + > +test_expect_success 'stdin fails on bad input line with only --bad-option' ' > + echo "--bad-option" >stdin && > + test_must_fail git update-ref --stdin err && > + grep "fatal: unknown option --bad-option" err > +' When you decomposed the monolithic test from v1 into individual tests, you dropped a couple cases ("fatal: unknown option'" and "fatal: unterminated single-quote"). Was this intentional? > +test_expect_success 'stdin fails with duplicate refs' ' > + cat >stdin <<-EOF && > +$a $m > +$b $m > +$a $m > +EOF > + test_must_fail git update-ref --stdin err && > + grep "fatal: Multiple updates for ref '"'"'$a'"'"' not allowed." err > +' The leading '-' on '-EOF' allows you to indent the content of the heredoc and the terminating EOF, which makes the test read nicely: test_expect_success 'stdin fails with duplicate refs' ' cat >stdin <<-EOF && $a $m $b $m $a $m EOF test_must_fail git update-ref ... ' > + > +test_expect_success 'stdin create ref works with no old value' ' > + echo "$a $m" >stdin && > + git update-ref --stdin + git rev-parse $m >expect && > + git rev-parse $a >actual && > + test_cmp expect actual > +'