GNU bug report logs -
#62406
“! failing-command” pattern in shell tests is wrong
Previous Next
Reported by: Ludovic Courtès <ludo <at> gnu.org>
Date: Thu, 23 Mar 2023 16:01:02 UTC
Severity: important
Done: Ludovic Courtès <ludo <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
On Tue, 2023-03-28 at 18:21 +0200, Ludovic Courtès wrote:
> Hi Eric,
>
> Eric Bavier <bavier <at> posteo.net> skribis:
>
> > The purpose of d89343 was to ease visual parsing of the tests. I mentioned
> > having used the '!' syntax in my own shell tests, but I realize now that I
> > was not relying on `set -e` like guix is.
> >
> > I'll consider a few options.
>
> Neat. I guess we could have a ‘lib.sh’ with an ‘expect_fail’ function
> or something.
>
Instead of a shared 'lib.sh', the attached patch uses 'cmd && false', which
has the desired semantics under 'set -e' and is no more verbose than a
wrapping function call.
If 'cmd' fails, the return status is ignored by 'set -e', which considers
only the return status of a command following the final '&&' or '||'. And
because 'cmd' failed the statement short-circuits without executing the
'false. Otherwise, if 'cmd' succeeds, the 'false' is executed and the shell
exits immediately.
In other places the '! test ...' pattern is replaced with 'test ! ...'.
There was some small amount of fall-out. I fixed a couple issues where I
could:
- tests/guix-archive.sh: added '--export' to command
- tests/guix-style.sh: added an escape to a sed pattern
But a couple others have failures I'm not as confident in fixing myself:
- tests/guix-refresh.sh: 'guix refresh' seems to not exit with a failure
status if a warning is issued, but the tests seem to think it should.
- tests/guix-git-authenticate.sh: A general failure to authenticate a
particular commit. This could be an issue with my test environment.
This patch should probably not be applied until those tests are fixed. I
would appreciate any help with that.
`~Eric
>
[0001-tests-Fix-checks-for-expected-failures.patch (text/x-patch, attachment)]
This bug report was last modified 2 years and 32 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.