Files
abap/bin/test
2022-07-13 18:12:56 +02:00

77 lines
2.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Synopsis:
# Test the track's exercises.
#
# At a minimum, this file must check if the example/exemplar solution of each
# Practice/Concept Exercise passes the exercise's tests.
#
# To check this, you usually have to (temporarily) replace the exercise's solution files
# with its exemplar/example files.
#
# If your track uses skipped tests, make sure to (temporarily) enable these tests
# before running the tests.
#
# The path to the solution/example/exemplar files can be found in the exercise's
# .meta/config.json file, or possibly inferred from the exercise's directory name.
# Example:
# ./bin/test
echo "Checking"
exit_code=0
# Verify the Concept Exercises
for concept_exercise_dir in ./exercises/concept/*/; do
if [ -d $concept_exercise_dir ]; then
echo "Checking $(basename "${concept_exercise_dir}") exercise..."
results_file_path="$(realpath "${concept_exercise_dir}")/results.json"
cp $(realpath "${concept_exercise_dir}")/.meta/*.clas.abap $(realpath "${concept_exercise_dir}")
/usr/bin/time -f 'Docker total runtime: %e seconds' docker run \
--rm \
--network none \
--mount type=bind,src="$(realpath "${concept_exercise_dir}")",dst=/solution \
--mount type=bind,src="$(realpath "${concept_exercise_dir}")",dst=/output \
--tmpfs /tmp:rw \
exercism/abap-test-runner $(basename "${concept_exercise_dir}") "/solution" "/output"
cat "${results_file_path}"
errors="$(cat "${results_file_path}" | grep "{\"version\":2,\"status\":\"pass\"" )"
if [ -z ${errors} ];
then
printf "\nError\n\n\n";
exit_code=1;
else
printf "\nNo Errors\n\n\n";
fi
fi
done
# Verify the Practice Exercises
for practice_exercise_dir in ./exercises/practice/*/; do
if [ -d $practice_exercise_dir ]; then
echo "Checking $(basename "${practice_exercise_dir}") exercise..."
results_file_path="$(realpath "${practice_exercise_dir}")/results.json"
cp $(realpath "${practice_exercise_dir}")/.meta/*.clas.abap $(realpath "${practice_exercise_dir}")
/usr/bin/time -f 'Docker total runtime: %e seconds' docker run \
--rm \
--network none \
--mount type=bind,src="$(realpath "${practice_exercise_dir}")",dst=/solution \
--mount type=bind,src="$(realpath "${practice_exercise_dir}")",dst=/output \
--tmpfs /tmp:rw \
exercism/abap-test-runner $(basename "${practice_exercise_dir}") "/solution" "/output"
cat "${results_file_path}"
errors="$(cat "${results_file_path}" | grep "{\"version\":2,\"status\":\"pass\"" )"
if [ -z ${errors} ];
then
printf "\nError\n\n\n";
exit_code=1;
else
printf "\nNo Errors\n\n\n";
fi
fi
done
exit ${exit_code}