Re: [PATCH 3/6] test_lib: allow test_{must,might}_fail to accept non-git on "sigpipe"
- From
Denton Liu <liu.denton@gmail.com>
- Date
- Jan 15, 2021, 08:15 UTC
- Message-ID
- <YAFPDJHH7ChvnVSD@generichostname>
- In-Reply-To
- <20210114233515.31298-4-avarab@gmail.com>
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:
Show 15 quoted lines
> 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/
Show 5 quoted lines
> 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 <avarab@gmail.com>