Skip to content

Commit

Permalink
test/system: Silence warning with Bats >= 1.7.0
Browse files Browse the repository at this point in the history
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
    bats-core/bats-core#547
    https://bats-core.readthedocs.io/en/stable/warnings/BW01.html

[2] bats-core/bats-core#367
    bats-core/bats-core#507
    https://bats-core.readthedocs.io/en/stable/writing-tests.html

[3] Bats commit 71d6b71cebc3d32b
    bats-core/bats-core#556
    https://bats-core.readthedocs.io/en/stable/warnings/BW02.html

containers#1081
  • Loading branch information
debarshiray authored and nievesmontero committed Aug 24, 2022
1 parent 1d448ce commit 910fdc5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion test/system/104-run.bats
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ teardown() {

create_default_container

run $TOOLBOX run $cmd
run -127 $TOOLBOX run $cmd

assert_failure
assert [ $status -eq 127 ]
Expand Down

0 comments on commit 910fdc5

Please sign in to comment.