git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: "SZEDER Gábor" <szeder.dev@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>,
	Git List <git@vger.kernel.org>
Subject: Re: [PATCH 1/2] t9400-git-cvsserver-server: don't rely on the output of 'test_cmp'
Date: Thu, 8 Mar 2018 13:51:17 -0500	[thread overview]
Message-ID: <CAPig+cTtV2unsixsMCWytdJMiYYytgdvbavfENhBrwvXq_79Bw@mail.gmail.com> (raw)
In-Reply-To: <20180308123844.15163-2-szeder.dev@gmail.com>

On Thu, Mar 8, 2018 at 7:38 AM, SZEDER Gábor <szeder.dev@gmail.com> wrote:
> The test 'cvs update (-p)' redirects and checks 'test_cmp's stdout and
> even its stderr.  The commit introducing this test in 6e8937a084
> (cvsserver: Add test for update -p, 2008-03-27) doesn't discuss why,
> in fact its log message only consists of that subject line.  Anyway,
> weird as it is, it kind of made sense due to the way that test was
> structured:

[excellent explanation snipped]

> Unroll that for loop, so we can check the files' contents the usual
> way and rely on 'test_cmp's exit code failing the && chain.  Extract
> updating a file via CVS and verifying its contents using 'test_cmp'
> into a helper function requiring the file's name as parameter to avoid
> much of the repetition resulting from unrolling the loop.

An alternative approach used elsewhere in the test suite[1] would be
simply to 'exit' if test_cmp fails:

    for i in merge no-lf empty really-empty; do
        GIT_CONFIG="$git_config" cvs update -p "$i" >$i.out
        test_cmp $i.out ../$i || exit 1
    done &&

(And, like the existing patch, this removes the need for capturing
test_cmp's output into a "failures" file.)

[1]: For example, the "setup" test of t2204-add-ignored.sh.

> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
> ---
> diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh
> @@ -447,12 +452,10 @@ test_expect_success 'cvs update (-p)' '
>      git push gitcvs.git >/dev/null &&
>      cd cvswork &&
>      GIT_CONFIG="$git_config" cvs update &&
> -    rm -f failures &&
> -    for i in merge no-lf empty really-empty; do
> -        GIT_CONFIG="$git_config" cvs update -p "$i" >$i.out
> -       test_cmp $i.out ../$i >>failures 2>&1
> -    done &&
> -    test -z "$(cat failures)"
> +    check_cvs_update_p merge &&
> +    check_cvs_update_p no-lf &&
> +    check_cvs_update_p empty &&
> +    check_cvs_update_p really-empty
>  '

  reply	other threads:[~2018-03-08 18:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-08 12:38 [PATCH 0/2] Make cvs tests pass with '-x' tracing and /bin/sh SZEDER Gábor
2018-03-08 12:38 ` [PATCH 1/2] t9400-git-cvsserver-server: don't rely on the output of 'test_cmp' SZEDER Gábor
2018-03-08 18:51   ` Eric Sunshine [this message]
2018-03-08 21:49     ` SZEDER Gábor
2018-03-08 22:01       ` Eric Sunshine
2018-03-08 22:07         ` Eric Sunshine
2018-03-08 22:38         ` SZEDER Gábor
2018-03-08 22:44         ` [PATCH v1.1 " SZEDER Gábor
2018-03-08 23:33           ` Junio C Hamano
2018-03-08 23:41             ` SZEDER Gábor
2018-03-08 23:44               ` Junio C Hamano
2018-03-09 11:20                 ` SZEDER Gábor
2018-03-08 12:38 ` [PATCH 2/2] t9402-git-cvsserver-refs: don't check the stderr of a subshell SZEDER Gábor
2018-03-13  0:05 ` [PATCH 0/2] Make cvs tests pass with '-x' tracing and /bin/sh Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPig+cTtV2unsixsMCWytdJMiYYytgdvbavfENhBrwvXq_79Bw@mail.gmail.com \
    --to=sunshine@sunshineco.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --cc=szeder.dev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).