-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntest.sh
More file actions
executable file
·68 lines (60 loc) · 1.25 KB
/
runtest.sh
File metadata and controls
executable file
·68 lines (60 loc) · 1.25 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env bash
set -e
set -o pipefail
usage() {
cat <<EOF
Usage: ${0##*/} [OPTION]...
Run unit test.
Options:
--docker run in the docker
--images run with docker image list, split by ,(default to $DOCKERIMAGE)
--help print this help and exit
--shell use shell instead of bash (default to $USESHELL).
EOF
}
USEDOCKER=0
DOCKERIMAGE="debian:10-slim,centos:7"
USESHELL="/bin/bash"
while [ $# -gt 0 ]; do
case "$1" in
--docker)
USEDOCKER=1
shift
;;
--images)
DOCKERIMAGE="$2"
shift 2
;;
-h | --help)
usage
exit 0
;;
--shell)
USESHELL="$2"
shift 2
;;
--)
shift 1
args+=("$@")
break
;;
-*)
echo >&2 "unknown option: $1"
exit 1
;;
*)
args+=("$1")
shift 1
;;
esac
done
exec="find ./tests -type f -name 'test_*.sh' -exec $USESHELL './{}' \;"
if [ "$USEDOCKER" -ne 0 ]; then
IFS=', ' read -r -a images <<<"$DOCKERIMAGE"
for image in "${images[@]}"; do
docker run -it --entrypoint /bin/bash -v "$(pwd):/codes" --rm "$image" -c "uname -a && cd /codes && $exec"
done
exit 0
fi
uname -a
eval "$exec"