test/system: Limit the scope of temporary files used by a single test
BATS_TMPDIR is the base directory used by Bats for all temporary files and directories, and BATS_TEST_TMPDIR is unique to each test [1]. It's better to limit the scope of the tests' temporary files as much as possible to avoid unexpected collisions with Bats' own internal temporary files. [1] https://bats-core.readthedocs.io/en/stable/writing-tests.html https://github.com/containers/toolbox/pull/1327
This commit is contained in:
parent
c43cf5d763
commit
ea91335ebb
2 changed files with 5 additions and 5 deletions
|
@ -166,11 +166,11 @@ teardown() {
|
|||
@test "run: 'sudo id' inside the default container" {
|
||||
create_default_container
|
||||
|
||||
output="$($TOOLBOX --verbose run sudo id 2>$BATS_TMPDIR/stderr)"
|
||||
output="$($TOOLBOX --verbose run sudo id 2>$BATS_TEST_TMPDIR/stderr)"
|
||||
status="$?"
|
||||
|
||||
echo "# stderr"
|
||||
cat $BATS_TMPDIR/stderr
|
||||
cat $BATS_TEST_TMPDIR/stderr
|
||||
echo "# stdout"
|
||||
echo $output
|
||||
|
||||
|
|
|
@ -227,9 +227,9 @@ function _clean_docker_registry() {
|
|||
|
||||
|
||||
function build_image_without_name() {
|
||||
echo -e "FROM scratch\n\nLABEL com.github.containers.toolbox=\"true\"" > "$BATS_TMPDIR"/Containerfile
|
||||
echo -e "FROM scratch\n\nLABEL com.github.containers.toolbox=\"true\"" > "$BATS_TEST_TMPDIR"/Containerfile
|
||||
|
||||
run $PODMAN build "$BATS_TMPDIR"
|
||||
run $PODMAN build "$BATS_TEST_TMPDIR"
|
||||
|
||||
assert_success
|
||||
assert_line --index 0 --partial "FROM scratch"
|
||||
|
@ -239,7 +239,7 @@ function build_image_without_name() {
|
|||
last=$((${#lines[@]}-1))
|
||||
assert_line --index "$last" --regexp "^[a-f0-9]{64}$"
|
||||
|
||||
rm -f "$BATS_TMPDIR"/Containerfile
|
||||
rm -f "$BATS_TEST_TMPDIR"/Containerfile
|
||||
|
||||
echo "${lines[$last]}"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue