forked from EricJMarti/inventory-hunter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_tests.bash
executable file
·43 lines (34 loc) · 863 Bytes
/
run_tests.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
set -e
usage() {
[ -n "$1" ] && echo "error: $1"
echo
echo "usage:"
echo " $0 [-i IMAGE]"
echo
exit 1
}
default_image="ericjmarti/inventory-hunter:latest"
image=$default_image
while getopts i: arg
do
case "${arg}" in
i) image=${OPTARG};;
esac
done
if [ "$image" = "$default_image" ]; then
docker pull "$image"
else
result=$(docker images -q $image)
if [ -z "$result" ]; then
echo "the $image docker image does not exist... please build the image and try again"
echo "build command: docker build -t $image ."
usage
fi
fi
script_dir=$(cd "$(dirname "$0")" && pwd -P)
tests_dir="$script_dir/tests"
volumes="-v $tests_dir:/src/tests"
docker_run_cmd="docker run --rm $volumes --entrypoint=pytest --workdir=/src $image"
echo "\$ $docker_run_cmd"
eval $docker_run_cmd