Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions bin/run-tests-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

# Synopsis:
# Test the test runner Docker image by running it against a predefined set of
# Test the test runner Docker image by running it against a predefined set of
# solutions with an expected output.
# The test runner Docker image is built automatically.

Expand All @@ -14,16 +14,34 @@ set -e
# Example:
# ./bin/run-tests-in-docker.sh

mnt_opt=""
run_opt=""
if ! command -v docker > /dev/null ; then
if ! command -v podman > /dev/null ; then
echo "Docker or Podman must be installed to run the tests in a container."
exit 1
fi
# Docker is unavailable, use Podman
docker() {
podman "$@"
}
# for SELinux systems, permit container access to mounted directories
mnt_opt=",Z"
# use same user ID for container, avoids file ownership problems
run_opt="--userns=keep-id"
fi
Comment thread
senekor marked this conversation as resolved.

# Build the Docker image
docker build --rm -t exercism/rust-test-runner .

# Run the Docker image using the settings mimicking the production environment
docker run \
--rm \
--network none \
--mount type=bind,src="${PWD}/tests",dst=/opt/test-runner/tests \
--mount type=bind,src="${PWD}/tests,dst=/opt/test-runner/tests$mnt_opt" \
--mount type=tmpfs,dst=/tmp \
--volume "${PWD}/bin/run-tests.sh:/opt/test-runner/bin/run-tests.sh" \
--mount type=bind,src="${PWD}/bin/run-tests.sh,dst=/opt/test-runner/bin/run-tests.sh$mnt_opt" \
$run_opt \
--workdir /opt/test-runner \
--entrypoint /opt/test-runner/bin/run-tests.sh \
exercism/rust-test-runner
2 changes: 1 addition & 1 deletion bin/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ for test_dir in tests/*; do
bin/run.sh "${slug}" "${test_dir_path}" "${test_dir_path}"

# Normalize the results file
jq 'if (.tests != null) then .tests |= sort_by(.name) else . end' "${results_file_path}" > tmp && mv tmp "${results_file_path}"
jq 'if (.tests != null) then .tests |= sort_by(.name) else . end' "${results_file_path}" > /tmp/res && mv /tmp/res "${results_file_path}"
sed -i -e 's/warning: build failed, waiting for other jobs to finish.*//' "${results_file_path}"

echo "${test_dir_name}: comparing results.json to expected_results.json"
Expand Down
Loading