-
Notifications
You must be signed in to change notification settings - Fork 55
/
tester.sh
executable file
·63 lines (51 loc) · 1.33 KB
/
tester.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
#!/usr/bin/env bash
# this script can be used to run tests in the container used for deployement.
# usage:
# Run all tests: ./tester.sh
# Run specific test: ./tester.sh path/to/test.t
set -e
shopt -s extglob
shopt -s inherit_errexit
if (( $# >= 1 )) && [[ "${1}" == "--no-build-container" ]]; then
NO_BUILD_CONTAINER=1
shift
else
NO_BUILD_CONTAINER=0
fi
if (( $# == 0 )); then
TESTS="tests/{filter{**/,},proxy}/*.t"
else
TESTS="$*"
fi
ARCH=$(arch)
if [ "$ARCH" = "arm64" ]; then
ARCH="aarch64"
fi
echo "running: ${TESTS}"
if (( ! NO_BUILD_CONTAINER )); then
docker buildx build \
--target=dev-local \
--tag=josh-dev-local \
--build-arg USER_UID="$(id -u)" \
--build-arg USER_GID="$(id -g)" \
--build-arg ARCH="${ARCH}" \
.
fi
mapfile -d '' TEST_SCRIPT << EOF
set -e
if [[ ! -v CARGO_TARGET_DIR ]]; then
echo "CARGO_TARGET_DIR not set"
exit 1
fi
export RUSTFLFAGS="-D warnings"
cargo build --workspace --exclude josh-ui --features hyper_cgi/test-server
( cd josh-ssh-dev-server ; go build -o "\${CARGO_TARGET_DIR}/josh-ssh-dev-server" )
sh run-tests.sh ${TESTS}
EOF
docker run -it --rm \
--workdir "$(pwd)" \
--volume "$(pwd)":"$(pwd)" \
--volume cache:/opt/cache \
--user "$(id -u)":"$(id -g)" \
josh-dev-local \
bash -c "${TEST_SCRIPT}"