2021-10-18 14:10:32 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
|
|
# Synopsis:
|
|
|
|
|
# Test the track's exercises.
|
2022-01-09 15:21:23 +01:00
|
|
|
#
|
|
|
|
|
# At a minimum, this file must check if the example/exemplar solution of each
|
2021-10-18 14:10:32 +02:00
|
|
|
# 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
|
2022-01-09 13:37:45 +01:00
|
|
|
echo "Checking"
|
2021-10-18 14:10:32 +02:00
|
|
|
|
2022-07-13 18:12:56 +02:00
|
|
|
exit_code=0
|
|
|
|
|
|
2021-10-18 14:10:32 +02:00
|
|
|
# Verify the Concept Exercises
|
2022-01-09 13:37:45 +01:00
|
|
|
for concept_exercise_dir in ./exercises/concept/*/; do
|
|
|
|
|
if [ -d $concept_exercise_dir ]; then
|
|
|
|
|
echo "Checking $(basename "${concept_exercise_dir}") exercise..."
|
2022-07-13 18:12:56 +02:00
|
|
|
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
|
2022-01-09 13:37:45 +01:00
|
|
|
fi
|
|
|
|
|
done
|
2021-10-18 14:10:32 +02:00
|
|
|
|
|
|
|
|
# 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..."
|
2022-01-09 13:37:45 +01:00
|
|
|
results_file_path="$(realpath "${practice_exercise_dir}")/results.json"
|
|
|
|
|
cp $(realpath "${practice_exercise_dir}")/.meta/*.clas.abap $(realpath "${practice_exercise_dir}")
|
2022-01-10 11:32:49 +01:00
|
|
|
/usr/bin/time -f 'Docker total runtime: %e seconds' docker run \
|
2022-01-09 13:37:45 +01:00
|
|
|
--rm \
|
2022-01-09 19:32:42 +01:00
|
|
|
--network none \
|
2022-01-09 13:37:45 +01:00
|
|
|
--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"
|
2022-02-11 15:34:39 +01:00
|
|
|
cat "${results_file_path}"
|
|
|
|
|
errors="$(cat "${results_file_path}" | grep "{\"version\":2,\"status\":\"pass\"" )"
|
2022-01-09 13:37:45 +01:00
|
|
|
|
2022-01-09 15:21:23 +01:00
|
|
|
if [ -z ${errors} ];
|
2022-02-11 15:34:39 +01:00
|
|
|
then
|
|
|
|
|
printf "\nError\n\n\n";
|
|
|
|
|
exit_code=1;
|
|
|
|
|
else
|
|
|
|
|
printf "\nNo Errors\n\n\n";
|
2022-01-09 13:37:45 +01:00
|
|
|
fi
|
2021-10-18 14:10:32 +02:00
|
|
|
fi
|
|
|
|
|
done
|
2022-01-09 13:37:45 +01:00
|
|
|
|
|
|
|
|
exit ${exit_code}
|