-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-test
executable file
·57 lines (44 loc) · 996 Bytes
/
run-test
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
#!/bin/bash
set -eo pipefail
set -x
cleanup() {
pkill caddy || true
}
# $1: path
# $2: additional flags
# Echos content
retry() {
local cnt=0
local -r THRES=10
while ! curl -sv $2 ${1} > /tmp/response; do
sleep 2
cnt=${cnt}+1
if [[ "$cnt" -gt "$THRES" ]]; then
exit 1
fi
done
cat /tmp/response
}
echobold() {
local -r bold=$(tput bold)
local -r normal=$(tput sgr0)
echo "${bold}${1}${normal}"
}
test() {
echobold "test case ${1}"
$XCADDY run --adapter caddyfile --config test/Caddyfile.${1}&
pid="$!"
retry $(cat test/test-${1}.req) > output${1}
diff output${1} test/test-${1}.res
cleanup
}
trap cleanup EXIT
#go get -v -u github.com/caddyserver/xcaddy/cmd/[email protected]
go install github.com/caddyserver/xcaddy/cmd/[email protected]
#readonly XCADDY="go run github.com/caddyserver/xcaddy/cmd/xcaddy"
readonly XCADDY="xcaddy"
$XCADDY list-modules
test "1"
test "2"
test "3"
test "4"