From 978bb524e45549b344b1bf5c09ed45b980c5f36d Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Sun, 31 Jul 2022 19:16:00 +0200 Subject: [PATCH] test/system: Silence warning with Bats >= 1.7.0 Bats 1.7.0 emits a warning if a command passed to 'run' returns with an exit code of 127 [1]: BW01: `run`'s command `/opt/bin/toolbox run non-existent-command` exited with code 127, indicating 'Command not found'. Use run's return code checks, e.g. `run -127`, to fix this message. (from function `run' in file /usr/lib/bats-core/test_functions.bash, line 299, in test file test/system/104-run.bats, line 148) This requires Bats >= 1.5.0, which is present in Fedora >=35, and supports specifying the exit code as an argument to Bats' 'run' command [2]. However, bats_require_minimum_version can't be used, because it's only available from Bats 1.7.0, which is new enough that it's absent from Fedora 35. [1] Bats commit c6dc2f88361a4f5b https://github.com/bats-core/bats-core/issues/547 https://bats-core.readthedocs.io/en/stable/warnings/BW01.html [2] https://github.com/bats-core/bats-core/pull/367 https://github.com/bats-core/bats-core/pull/507 https://bats-core.readthedocs.io/en/stable/writing-tests.html [3] Bats commit 71d6b71cebc3d32b https://github.com/bats-core/bats-core/issues/556 https://bats-core.readthedocs.io/en/stable/warnings/BW02.html https://github.com/containers/toolbox/pull/1081 --- test/system/104-run.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/system/104-run.bats b/test/system/104-run.bats index 4afa881..7e6217c 100644 --- a/test/system/104-run.bats +++ b/test/system/104-run.bats @@ -145,7 +145,7 @@ teardown() { create_default_container - run $TOOLBOX run $cmd + run -127 $TOOLBOX run $cmd assert_failure assert [ $status -eq 127 ]