bug-guix
[Top][All Lists]
Advanced

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

bug#62406: “! failing-command” pattern in shell tests is wrong


From: Eric Bavier
Subject: bug#62406: “! failing-command” pattern in shell tests is wrong
Date: Thu, 20 Apr 2023 05:48:55 +0000

On Tue, 2023-03-28 at 18:21 +0200, Ludovic Courtès wrote:
> Hi Eric,
> 
> Eric Bavier <bavier@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
> 

Attachment: 0001-tests-Fix-checks-for-expected-failures.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]