-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_tests
131 lines (117 loc) · 3.74 KB
/
run_tests
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
# vim: sw=4 ts=4 ft=perl
set -e
ME="${BASH_SOURCE[0]}"
mydir=$(cd $(dirname $ME) && pwd)
cd $mydir
container="robkinyon/net-curl-parallel-test"
# Broken:
# 5.10 and 5.12 don't build
# Configure failed for Dist-Zilla-6.010.
all_versions="5.14 5.16 5.18 5.20 5.22 5.24 5.26"
# This is to handle GitBash's auto-mangling of path names when interacting
# with Docker. Without this, Docker cannot mount volumes properly.
export MSYS_NO_PATHCONV=1
# In Linux, files written within a container into a mounted volume are written
# as the root user, specifically id=0. This causes issues because those files
# have to be "sudo rm" to be removed.
# q.v. https://denibertovic.com/posts/handling-permissions-with-docker-volumes/
# for a deeper explanation and q.v. http://disq.us/p/1gy6ysh for how the
# following answer works.
# TODO: Make this work on OSX and Windows.
fix_for_root_user_in_container=""
# -v /etc/group:/etc/group:ro -v /etc/passwd:/etc/passwd:ro
# -u $(id -u):$(id -g)
#"
files_dirs_to_map=(
lib t dist.ini
.git README.md
)
volumes=(-v $(pwd)/.pause:/app/.pause)
for item in ${files_dirs_to_map[@]}; do
volumes+=(-v $(pwd)/$item:/app/$item)
done
versions=${PERL_VERSIONS:-${all_versions}}
if [[ "$1" == "bash" ]]; then
version="5.26"
MSYS_NO_PATHCONV=1 \
docker run \
-it --rm \
$fix_for_root_user_in_container \
"${volumes[@]}" \
${container}:${version} \
bash
elif [[ "$1" == "pull" ]]; then
shift
for version in ${versions}; do
docker pull perl:${version}
done
elif [[ "$1" == "build" ]]; then
shift
mkdir -p build_log
for version in ${versions}; do
echo "Running build for perl-${version}"
set +e
(
cat Dockerfile.test | sed "s/{{version}}/${version}/" \
> Dockerfile.${version}
docker build -t ${container}:${version} -f Dockerfile.${version} .
rm Dockerfile.${version}
) &>build_log/${version}.log
set -e
done
elif [[ "$1" == "test" ]]; then
shift
test_command="${@:-""}"
for version in ${versions}; do
echo "Running tests against perl-${version}"
MSYS_NO_PATHCONV=1 \
docker run \
-it --rm \
$fix_for_root_user_in_container \
-e "NET_CURL_PARALLEL_NETWORK_TESTS=${NET_CURL_PARALLEL_NETWORK_TESTS:-1}" \
-e "TEST_AUTHOR=${TEST_AUTHOR:-1}" \
"${volumes[@]}" \
${container}:${version} \
$test_command
done
elif [[ "$1" == "cover" ]]; then
shift
for version in ${versions}; do
echo "Running test coverage against perl-${version}"
rm -rf cover_db cover_db_${version}
mkdir cover_db
MSYS_NO_PATHCONV=1 \
docker run \
-it --rm \
$fix_for_root_user_in_container \
-e "NET_CURL_PARALLEL_NETWORK_TESTS=${NET_CURL_PARALLEL_NETWORK_TESTS:-1}" \
-e "TEST_AUTHOR=${TEST_AUTHOR:-1}" \
"${volumes[@]}" \
${container}:${version} \
cover
mv cover_db cover_db_${version}
done
elif [[ "$1" == "release" ]]; then
shift
if [[ ! -f "$HOME/.pause" ]]; then
>&2 echo "No ~/.pause file found."
exit 1
fi
# Because of an interaction between Docker-toolbox and Git-bash, we have to
# copy the .pause here out of $HOME.
cp "$HOME/.pause" .
tag=5.26
if [[ -z $(docker images -q ${container}:${tag}) ]]; then
$ME build ${tag}
fi
docker run \
--rm \
"${volumes[@]}" \
--entrypoint bash \
${container}:${tag} \
-c "dzil release"
else
>&2 echo "${ME}: <pull | build | test | unit integration | cover | release> [command]"
exit 1
fi