diff options
author | Joseph Hunkeler <jhunkeler@users.noreply.github.com> | 2024-11-06 08:55:52 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-06 08:55:52 -0500 |
commit | 52e6d0f495023c0aa939bf6b2170ca5ea853202b (patch) | |
tree | 897a87316c280b6824892368662afcb848de1cf6 /tests/setup.sh | |
parent | 6db1b15b5c62d6fb52825c1d833ac8dfa9a49fbb (diff) | |
parent | 46ae10e55603b8852612ebe12c7636c2b358bdd6 (diff) | |
download | stasis-52e6d0f495023c0aa939bf6b2170ca5ea853202b.tar.gz |
Merge pull request #67 from jhunkeler/safety-and-convenience
Safety and convenience
Diffstat (limited to 'tests/setup.sh')
-rw-r--r-- | tests/setup.sh | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/tests/setup.sh b/tests/setup.sh index 0875cac..50209ae 100644 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -24,7 +24,15 @@ setup_script_dir="$(dirname ${BASH_SOURCE[0]})" export TOPDIR=$(pwd) export TEST_DATA="$TOPDIR"/data -WS_DEFAULT=rt_workspace_ +pushd() { + command pushd "$@" 1>/dev/null +} + +popd() { + command popd 1>/dev/null +} + +WS_DEFAULT="workspaces/rt_workspace_" setup_workspace() { if [ -z "$1" ]; then echo "setup_workspace requires a name argument" >&2 @@ -253,8 +261,18 @@ assert_file_contains() { fi } +clean_up_docker() { + CONTAINERS_DIR="$WORKSPACE/.local/share/containers" + # HOME points to the WORKSPACE. The only reason we'd have this directory is if docker/podman was executed + # Fair to assume if the directory exists, docker/podman is functional. + if [ -d "$CONTAINERS_DIR" ]; then + docker run --rm -it -v $CONTAINERS_DIR:/data alpine sh -c '/bin/rm -r -f /data/*' + fi +} + clean_up() { - if [ -z "$RT_KEEP_WORKSPACE" ] && [ -d "$WORKSPACE" ]; then + if ([ -z "$RT_KEEP_WORKSPACE" ] || [ -z "$KEEP_WORKSPACE" ]) && [ -d "$WORKSPACE" ]; then + clean_up_docker rm -rf "$WORKSPACE" fi |