Files
abap-test-runner/bin/run-in-docker.sh
2021-11-24 06:48:56 +01:00

45 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env sh
# Synopsis:
# Run the test runner on a solution using the test runner Docker image.
# The test runner Docker image is built automatically.
# Arguments:
# $1: exercise slug
# $2: path to solution folder
# $3: path to output directory
# Output:
# Writes the test results to a results.json file in the passed-in output directory.
# The test results are formatted according to the specifications at https://github.com/exercism/docs/blob/main/building/tooling/test-runners/interface.md
# Example:
# ./bin/run-in-docker.sh two-fer path/to/solution/folder/ path/to/output/directory/
# If any required arguments is missing, print the usage and exit
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
echo "usage: ./bin/run-in-docker.sh exercise-slug path/to/solution/folder/ path/to/output/directory/"
exit 1
fi
slug="$1"
solution_dir=$(realpath "${2%/}")
output_dir=$(realpath "${3%/}")
# Create the output directory if it doesn't exist
mkdir -p "${output_dir}"
# Build the Docker image
docker build --rm -t exercism/test-runner .
# Run the Docker image using the settings mimicking the production environment
docker run \
--rm \
--read-only \
--network none \
--mount type=bind,src="${solution_dir}",dst=/solution \
--mount type=bind,src="${output_dir}",dst=/output \
exercism/test-runner "${slug}" "//solution" "//output"
# --mount type=tmpfs,dst=/tmp \
# https://stackoverflow.com/questions/48427366/docker-build-command-add-c-program-files-git-to-the-path-passed-as-build-argu