Re: [PATCH v4 5/6] tests: don't lose "git" exit codes in "! ( git ... | grep )"

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

 



Phillip Wood <phillip.wood123@xxxxxxxxx> writes:

> It seems strange to use sed here, you could just keep using grep and
> check the output is empty if you don't want to use
> test_expect_code.

I am not sure what you mean by test_expect_code, but we can do the
"! grep -e pattern file" to ensure that the unwanted pattern does
not exist.  Unlike our command, we do not worry about system "grep"
being buggy, so if it yields non-zero, it is because no line in the
file matches the pattern.  After all, that is what the original code
fixed by this patch wanted to check.

The "do not lose exit code of the git command" part of the goal is
achieved by breaking the pipeline already, and we can keep the test
that uses grep.

Having said that, switching to "sed" is not too bad.  If we wanted
to expect N lines that matches the pattern in the file, with grep,
we need to do "! grep" dance when (and only when) N is zero.  With
sed, we do not have to worry about it.

> There is also no need to redirect the input of the
> sed commands.

That's true.



[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