Re: [PATCH 1/2] t9400-git-cvsserver-server: don't rely on the output of 'test_cmp'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 8, 2018 at 7:38 AM, SZEDER Gábor <szeder.dev@xxxxxxxxx> 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@xxxxxxxxx>
> ---
> 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
>  '




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux