-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
accomodate bsd-like macos with some tweaks to test script
focused more on functions and returns rather than exiting subprocesses
- Loading branch information
1 parent
7fb6673
commit 09282e4
Showing
1 changed file
with
40 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |