-
Notifications
You must be signed in to change notification settings - Fork 5
/
test.sh
executable file
·69 lines (61 loc) · 1.28 KB
/
test.sh
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
69
#!/bin/bash
cd "${0%/*}" || exit
set -e
build=0
examples=0
mark=""
while [ $# -gt 0 ]; do
case "$1" in
-b|--build)
build=1
shift
;;
-m|--mark)
shift
if [ $# -gt 0 ]; then
mark=$1
else
echo "no mark specified"
exit 1
fi
shift
;;
--examples)
shift
examples=1
;;
*)
echo "invalid parameter $1"
exit 1
;;
esac
done
# build
if [ $build -eq 1 ]; then
bash ./build.sh
fi
if [ $examples -eq 1 ]; then
# run example tests
docker run \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(pwd)/examples:/var/task \
cowait/task \
bash ./test_examples.sh
else
# run package tests
cmd="pytest"
extra_args=""
# pytest mark filter
if [ -n "$mark" ]; then
cmd="$cmd -m $mark"
fi
# if the build flag is not set, mount the local directory
if [ $build -eq 0 ]; then
extra_args="-v $(pwd):/var/cowait"
fi
docker run $extra_args \
-v /var/run/docker.sock:/var/run/docker.sock \
--workdir /var/cowait \
cowait/task \
$cmd
fi