Skip to content

Commit

Permalink
accomodate bsd-like macos with some tweaks to test script
Browse files Browse the repository at this point in the history
focused more on functions and returns rather than exiting subprocesses
  • Loading branch information
tomeichlersmith committed Aug 22, 2024
1 parent 7fb6673 commit 09282e4
Showing 1 changed file with 40 additions and 18 deletions.
58 changes: 40 additions & 18 deletions test/gui/run-gui-test
Original file line number Diff line number Diff line change
@@ -1,26 +1,48 @@
#!/usr/bin/sh

# check if we can open xeyes and view it from denv
# only run this with docker machines right now

set -o nounset
set -o errexit
docker_check() {
if ! command -v docker > /dev/null 2>&1; then
printf "docker not available. Not running test."
return 1
fi
return 0
}

build_test_image() {
cd "${1}" || return 1
docker build . -t "${2}"
}

if ! command -v docker > /dev/null 2>&1; then
printf "docker not available. Not running test."
exit 1
fi
run_gui_test() {
cd "${1}" || return 1
"${2}" init --clean-env "${3}:latest" || return 2
"${2}" xeyes || return 3
cd || return 4
rm -r "${1}"
}

_run_gui_test_dir="$(cd -- "$(dirname -- "$0")" && pwd)"
_denv_dir="$(cd -- "${_run_gui_test_dir}/../../" && pwd)"
_denv="${_denv_dir}/denv"
_test_image_name="denv-gui-test-image"
main() {
_run_gui_test_dir="$(cd -- "$(dirname -- "$0")" && pwd)"
_denv_dir="$(cd -- "${_run_gui_test_dir}/../../" && pwd)"
_denv="${_denv_dir}/denv"
_test_image_name="denv-gui-test-image"

cd "${_run_gui_test_dir}/image"
docker build . -t "${_test_image_name}"
docker_check || return $?

build_test_image \
"${_run_gui_test_dir}/image" \
"${_test_image_name}" || return $?

# need to accomodate mktemp on either GNU (left) or BSD (right)
test_d=$(mktemp -d 2> /dev/null || mktemp -d -t 'denv-test-gui-tmpdir')

run_gui_test \
"${test_d}" \
"${_test_image_name}" \
"${_denv}"
}

test_d=$(mktemp --directory)
cd "${test_d}"
"${_denv}" init --clean-env "${_test_image_name}:latest"
"${_denv}" xeyes
cd
rm -r "${test_d}"
main

0 comments on commit 09282e4

Please sign in to comment.