Re: [PATCH 3/6] test_lib: allow test_{must,might}_fail to accept non-git on "sigpipe"
From: Denton Liu <hidden>
Date: 2021-01-15 08:16:09
Hi Ævar, First of all, thanks for reviving this series! I hope that Bash accepts your proposed patch because it would definitely be helpful. On Fri, Jan 15, 2021 at 12:35:12AM +0100, Ævar Arnfjörð Bjarmason wrote:
As the documentation here notes you usually do not want to do:
test_might_fail grep ...
But instead:
! grep ...
However, as a future commit will show it's handy to be able to do:
some | test_might_fail ok=sigpipe grep | commands | here
To allow "grep" to fail in the middle of a pipe, if we're in a mode
such as a "set -o pipefail" that knows how to accept check intra-pipe
failures.
From what I can see, there presently aren't any other use cases here
except for with grep. I propose writing a wrapper around
grep, à la [0]:
test_filter () {
grep "$@" || :
}
This has two main advantanges: the first would be that we could avoid
complicating the test_must_fail_acceptable() code. The second is that
it would be much less of a mouthful to write and it would be more
readable.
Compare
some | test_might_fail ok=sigpipe grep | commands | here
to
some | test_filter | commands | here
Thanks,
Denton
[0]: https://lore.kernel.org/git/3f79d23b40c0586d0351f4d721097be4f7ba26b8.1573779465.git.liu.denton@gmail.com/ (local)
To test this in t0000-basic.sh we don't actually need to have
test_{might,must}_fail in the middle of a pipe, it'll just that it
accepts e.g. "grep" when we provide ok=sigpipe.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>