From: Eric Sunshine Date: Tue, 01 Sep 2015 22:26:15 GMT Subject: Re: [PATCH v2 3/6] t6300: introduce test_date() helper Message-ID: In-Reply-To: <8e869f362971a44bb1f40ca5fed98b658efaa0dd.1441144343.git.john@keeping.me.uk> On Tue, Sep 1, 2015 at 5:55 PM, John Keeping wrote: > This moves the setup of the "expected" file inside the test case. The > helper function has the advantage that we can use SQ in the file content > without needing to escape the quotes. > > Signed-off-by: John Keeping > --- > diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh > index 7c9bec7..5fdb964 100755 > --- a/t/t6300-for-each-ref.sh > +++ b/t/t6300-for-each-ref.sh > @@ -146,85 +146,54 @@ test_expect_success 'Check invalid format specifiers are errors' ' > test_must_fail git for-each-ref --format="%(authordate:INVALID)" refs/heads > ' > > -cat >expected <<\EOF > -'refs/heads/master' 'Mon Jul 3 17:18:43 2006 +0200' 'Mon Jul 3 17:18:44 2006 +0200' > -'refs/tags/testtag' 'Mon Jul 3 17:18:45 2006 +0200' > -EOF > +test_date () { > + f=$1 f=$1 && > + committer_date=$2 && > + author_date=$3 && > + tagger_date=$4 && > + cat >expected <<-EOF && > + 'refs/heads/master' '$committer_date' '$author_date' > + 'refs/tags/testtag' '$tagger_date' > + EOF > + ( > + git for-each-ref --shell --format="%(refname) %(committerdate${f:+:$f}) %(authordate${f:+:$f})" refs/heads && > + git for-each-ref --shell --format="%(refname) %(taggerdate${f:+:$f})" refs/tags > + ) >actual && > + test_cmp expected actual > +}