33set -e
44
55# Synopsis:
6- # Test the test runner Docker image by running it against a predefined set of
6+ # Test the test runner Docker image by running it against a predefined set of
77# solutions with an expected output.
88# The test runner Docker image is built automatically.
99
@@ -14,16 +14,34 @@ set -e
1414# Example:
1515# ./bin/run-tests-in-docker.sh
1616
17+ mnt_opt=" "
18+ run_opt=" "
19+ if ! command -v docker > /dev/null ; then
20+ if ! command -v podman > /dev/null ; then
21+ echo " Docker or Podman must be installed to run the tests in a container."
22+ exit 1
23+ fi
24+ # Docker is unavailable, use Podman
25+ docker () {
26+ podman " $@ "
27+ }
28+ # for SELinux systems, permit container access to mounted directories
29+ mnt_opt=" ,Z"
30+ # use same user ID for container, avoids file ownership problems
31+ run_opt=" --userns=keep-id"
32+ fi
33+
1734# Build the Docker image
1835docker build --rm -t exercism/rust-test-runner .
1936
2037# Run the Docker image using the settings mimicking the production environment
2138docker run \
2239 --rm \
2340 --network none \
24- --mount type=bind,src=" ${PWD} /tests" ,dst=/opt/test-runner/tests \
41+ --mount type=bind,src=" ${PWD} /tests,dst=/opt/test-runner/tests$mnt_opt " \
2542 --mount type=tmpfs,dst=/tmp \
26- --volume " ${PWD} /bin/run-tests.sh:/opt/test-runner/bin/run-tests.sh" \
43+ --mount type=bind,src=" ${PWD} /bin/run-tests.sh,dst=/opt/test-runner/bin/run-tests.sh$mnt_opt " \
44+ $run_opt \
2745 --workdir /opt/test-runner \
2846 --entrypoint /opt/test-runner/bin/run-tests.sh \
2947 exercism/rust-test-runner
0 commit comments