Re: [GSoC][PATCH v4] test: avoid pipes in git related commands for test

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

 



On Fri, Mar 23, 2018 at 11:01 AM, Pratik Karki <predatoramigo@xxxxxxxxx> wrote:
> I hope this follow-on patch[1] is ready for merge.

This iteration appears to address review comments from the last few
rounds, however, see below for a few new ones...

> Avoid using pipes downstream of Git commands since the exit codes
> of commands upstream of pipes get swallowed, thus potentially
> hiding failure of those commands. Instead, capture Git command
> output to a file and apply the downstream command(s) to that file.
>
> Signed-off-by: Pratik Karki <predatoramigo@xxxxxxxxx>
> ---
> diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
> @@ -840,8 +840,8 @@ test_expect_success C_LOCALE_OUTPUT 'fetch aligned output' '
>         test_commit looooooooooooong-tag &&
>         (
>                 cd full-output &&
> -               git -c fetch.output=full fetch origin 2>&1 | \
> -                       grep -e "->" | cut -c 22- >../actual
> +               git -c fetch.output=full fetch origin >actual2 2>&1 &&
> +               grep -e "->" actual2 | cut -c 22- >../actual

The file "actual2" is clearly distinct from the file "../actual", so
inventing a name ("actual2") isn't particularly helping; you could
just as easily also name it "actual" without hurting comprehension.
(Not necessarily worth a re-roll.)

>         ) &&
> @@ -855,8 +855,8 @@ test_expect_success C_LOCALE_OUTPUT 'fetch compact output' '
>         test_commit extraaa &&
>         (
>                 cd compact &&
> -               git -c fetch.output=compact fetch origin 2>&1 | \
> -                       grep -e "->" | cut -c 22- >../actual
> +               git -c fetch.output=compact fetch origin >actual2 2>&1 &&
> +               grep -e "->" actual2 | cut -c 22- >../actual

Same comment.

>         ) &&
> diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh
> @@ -74,11 +74,12 @@ test_expect_success 'iso-8859-1' '
>         git commit -s -m den file &&
> -       git fast-export wer^..wer |
> -               sed "s/wer/i18n/" |
> +       git fast-export wer^..wer >actual &&
> +       sed "s/wer/i18n/" actual |
>                 (cd new &&
>                  git fast-import &&
> -                git cat-file commit i18n | grep "Áéí óú")
> +                git cat-file commit i18n >actual &&
> +                grep "Áéí óú" actual)

It was a bit surprising to see a new "actual" file created inside the
subshell even as 'sed' is processing a file named "actual" outside the
subshell, and, as a reader, I was concerned about bad interaction
between the operations. However, the file in the subshell is really
"new/actual", thus is distinct from the other "actual", so it's okay.

This is one of those cases, however, in which it might make sense to
give the files different names to make the code easier to grok, so
future readers don't stumble over this as well. For instance, the
outer file could be named "iso8859-1.fi" (or something), and the file
in the subshell can remain "actual". Not itself worth a re-roll, but
probably a good idea.

(This differs in couple ways from my comment above about t5510 tests
naming files "actual2" and "../actual". In that case, it was quite
clear that, within the cd'd subshell, file "../actual" was distinct
from the file created within the cd'd directory, so no confusion.
Moreover, those files were not being accessed at the same time,
whereas in this t9350 test, the 'sed' is reading from the a file at
the same time as 'git cat-file' is outputting to a similarly named
file, which is potentially confusing and requires extra brain cycles
to sort out.)

>  '
> @@ -87,18 +88,16 @@ test_expect_success 'import/export-marks' '
>         test_line_count = 3 tmp-marks &&
> -       test $(
> -               git fast-export --import-marks=tmp-marks\
> -               --export-marks=tmp-marks HEAD |
> -               grep ^commit |
> +       git fast-export --import-marks=tmp-marks \
> +               --export-marks=tmp-marks HEAD >actual &&
> +       test $(grep ^commit actual |
>                 wc -l) \
>         -eq 0 &&

Since the git-fast-export invocation has been pulled out of the
$(...), the entire 'test' expression is now short enough to fit easily
on one line. Making such a change would improve readability
considering how hard it is to read split over three lines like that
(with inconsistent indentation, moreover):

    test $(grep ^commit actual | wc -l) -eq 0 &&

>         echo change > file &&
>         git commit -m "last commit" file &&
> -       test $(
> -               git fast-export --import-marks=tmp-marks \
> -               --export-marks=tmp-marks HEAD |
> -               grep ^commit\  |
> +       git fast-export --import-marks=tmp-marks \
> +               --export-marks=tmp-marks HEAD >actual &&
> +       test $(grep ^commit\  actual |
>                 wc -l) \
>         -eq 1 &&

Same comment.

>         test_line_count = 4 tmp-marks
> @@ -500,13 +501,13 @@ test_expect_success 'refs are updated even if no commits need to be exported' '
>         git fast-export --import-marks=tmp-marks \
>                 --export-marks=tmp-marks master > /dev/null &&
>         git fast-export --import-marks=tmp-marks \
> -               --export-marks=tmp-marks master > actual &&
> +               --export-marks=tmp-marks master >actual &&

This change is unrelated to the purpose of this patch, thus is noise
which distracts reviewers from real changes. Fixing style problems in
code you're touching is fine (and usually recommended), however, this
code is outside the scope of what the patch should be touching (there
is no piping output of a git command here). Moreover, it doesn't make
sense to fix only "> actual" but not "> /dev/null" just above it.
Consequently, this change should be dropped from the patch.

>         test_cmp expected actual
>  '




[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