Re: [PATCH 0/2] microproject: avoid using pipes in test

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

 



> I think these changes are good, but it's not the case that we try to
> avoid using pipes at all in our tests.
>
> It's often a hassle, and just not worth it, e.g.:
>
>     oid=$(echo foo | git hash-object --stdin -w) &&
>
> Sure, we can make that:
>
>     echo foo >in &&
>     oid=$(git hash-object --stdin -w <in) &&
>
> But in the general case it's not worth worrying about.
>
> What we *do* try to avoid, and what's actually important is to never
> invoke "git" or other programs we invoke on the LHS of a pipe, or to
> otherwise do so in a way that hides potential errors.

Sorry, I have not mentioned it properly in the message but my
intention is not to remove all pipes but to remove only those, which
have "git" command in LHS.

> That's not isolated to just pipes, but e.g. calling it within helper
> functions that don't &&-chain, but pipes are probably the most common
> offender.
>
> The reason we do that is because in hacking git we may make it error,
> segfault etc. If it's on the LHS of a pipe that failure becomes
> indistinguishable from success.
>
> And if the test is really checking e.g. "when I run git like this, it
> produces no output" printing nothing with an exit of 0 will become the
> same as a segafault for the purposes of test.
>
> And that's bad.
>
> But just invoking things on the LHS of a pipe? Sometimes it's a good
> thing not do do that, because we'll be able to see a failure more
> incrementally, and with intermediate files.
>
> But it's generally not a problem, our test suite assumes that the OS is
> basically sane. We're not going to call every invocation of "sed",
> "grep" etc. with a wrapper like "test_must_fail grep" instead of "!
> grep".
>
> The same goes for our own helper utility functions such as "q_to_nul"
> etc, as long as (and this is critical) that they're implemented by
> shelling out to "sed", "grep", "perl" or whatever, and not to "git" or
> "test-tool" etc. Then we need to start being as paranoid about them as
> "git" on the LHS of pipes.

Thanks here for providing me with a broader context of the problem.
What I understand,
It's not just about "git" on LHS of pipes but more broader to anything
custom where
We can miss exit codes but I think as a low hanging fruit I can start
with "git" on LHS of pipe
and as I will understand the codebase more I can work on other custom
helpers too.

Thanks,
Shubham



[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