test/system: Simplify running a subset of the tests with Bats >= 1.7.0
The 000-setup.bats and 999-teardown.bats files were added [1] at a time when Bats didn't offer any hooks for suite-wide setup and teardown. That changed in Bats 1.7.0, which introduced the setup_suite and teardown_suite hooks. These hooks make it easier to run a subset of the tests, which is a good thing. In the past, to run a subset of the tests, one had to do: $ bats ./test/system/000-setup.bats ./test/system/002-help.bats \ ./test/system/999-teardown.bats Now, one only has to do: $ bats ./test/system/002-help.bats Commite22a82fec8
already added a dependency on Bats >= 1.7.0. Therefore, it should be exploited wherever possible to simplify things. [1] Commit54a2ca1ead
https://github.com/containers/toolbox/issues/751 [2] Bats commit fb467ec3f04e322a https://github.com/bats-core/bats-core/issues/39 https://bats-core.readthedocs.io/en/stable/writing-tests.html https://github.com/containers/toolbox/pull/1317
This commit is contained in:
parent
c37c5238dd
commit
7a387dcc8b
2 changed files with 15 additions and 27 deletions
|
@ -1,26 +0,0 @@
|
|||
#!/usr/bin/env bats
|
||||
#
|
||||
# Copyright © 2021 – 2022 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
load 'libs/helpers'
|
||||
|
||||
@test "test suite: Teardown" {
|
||||
_setup_environment
|
||||
|
||||
_clean_cached_images
|
||||
_clean_docker_registry
|
||||
_clean_temporary_storage
|
||||
}
|
|
@ -17,7 +17,10 @@
|
|||
|
||||
load 'libs/helpers'
|
||||
|
||||
@test "test suite: Set up" {
|
||||
setup_suite() {
|
||||
bats_require_minimum_version 1.7.0
|
||||
echo "# test suite: Set up" >&3
|
||||
|
||||
local os_release="$(find_os_release)"
|
||||
local system_id="$(get_system_id)"
|
||||
local system_version="$(get_system_version)"
|
||||
|
@ -42,3 +45,14 @@ load 'libs/helpers'
|
|||
|
||||
_setup_docker_registry
|
||||
}
|
||||
|
||||
teardown_suite() {
|
||||
bats_require_minimum_version 1.7.0
|
||||
echo "# test suite: Tear down" >&3
|
||||
|
||||
_setup_environment
|
||||
|
||||
_clean_cached_images
|
||||
_clean_docker_registry
|
||||
_clean_temporary_storage
|
||||
}
|
Loading…
Reference in a new issue