Re: [PATCH v2 3/6] t6300: introduce test_date() helper
On Tue, Sep 1, 2015 at 5:55 PM, John Keeping <john@keeping.me.uk> wrote:
Show 20 quoted lines
> 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 <john@keeping.me.uk>
> ---
> 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=$1Show 13 quoted lines
> + 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
> +}