test/system: Clarify the use of Git submodules

We wasted some time trying to get the tests running locally, when all we
were missing were the 'git submodule ...' commands.

Add some more obvious hints about this possible stumbling block.

Note that Bats cautions against printing outside the @test, setup* or
teardown* functions [1].  In this case, doing so leads to the first line
of the error output going missing, when using the pretty formatter for
human consumption:

  $ bats --formatter pretty ./test/system
   ✗ setup_suite
     Forgot to run 'git submodule init' and 'git submodule update' ?
     bats warning: Executed 1 instead of expected 191 tests

  191 tests, 1 failure, 190 not run

[1] https://bats-core.readthedocs.io/en/stable/writing-tests.html

https://github.com/containers/toolbox/pull/1298

Signed-off-by: Matthias Clasen <mclasen@redhat.com>
This commit is contained in:
Matthias Clasen 2023-05-18 06:58:55 -04:00 committed by Debarshi Ray
parent 7a387dcc8b
commit 2c09606603
2 changed files with 19 additions and 2 deletions

View file

@ -22,7 +22,8 @@ Running them won't remove any existing containers or images.
These tests use a few standard libraries for `bats` which help with clarity
and consistency. The libraries are [bats-support](https://github.com/bats-core/bats-support)
and [bats-assert](https://github.com/bats-core/bats-assert). These libraries are
provided as git submodules in the `libs` directory. Make sure both are present.
provided as git submodules in the `libs` directory. Make sure both are present
by running `git submodule init` and `git submodule update`.
## How to run the tests

View file

@ -15,12 +15,24 @@
# limitations under the License.
#
load 'libs/helpers'
missing_dependencies=false
if [ -f test/system/libs/bats-assert/load.bash ] && [ -f test/system/libs/bats-support/load.bash ]; then
load 'libs/helpers'
else
missing_dependencies=true
fi
setup_suite() {
bats_require_minimum_version 1.7.0
echo "# test suite: Set up" >&3
if $missing_dependencies; then
echo "# Missing dependencies" >&3
echo "# Forgot to run 'git submodule init' and 'git submodule update' ?" >&3
return 1
fi
local os_release="$(find_os_release)"
local system_id="$(get_system_id)"
local system_version="$(get_system_version)"
@ -50,6 +62,10 @@ teardown_suite() {
bats_require_minimum_version 1.7.0
echo "# test suite: Tear down" >&3
if $missing_dependencies; then
return 0
fi
_setup_environment
_clean_cached_images