From 69c30ad492f6a52f83ce94fea384f92065cb09ca Mon Sep 17 00:00:00 2001 From: Marian Zeis <13335743+marianfoo@users.noreply.github.com> Date: Sun, 9 Jan 2022 13:37:45 +0100 Subject: [PATCH] add test exercise script (#40) --- .github/workflows/test.yml | 2 +- bin/test | 36 +++++++++++++++++++++++++++++------- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bdfcd10..069e67b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,4 +36,4 @@ jobs: - run: abaplint abaplint_exercises.json - run: abaplint abaplint_solutions.json - name: Run tests for all exercises - run: bin/test + run: sh ./bin/test diff --git a/bin/test b/bin/test index 8d31328..5175fdf 100755 --- a/bin/test +++ b/bin/test @@ -17,19 +17,41 @@ # Example: # ./bin/test +echo "Checking" # 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..." - # TODO: run command to verify that the exemplar solution passes the tests - fi -done + for concept_exercise_dir in ./exercises/concept/*/; do + if [ -d $concept_exercise_dir ]; then + echo "Checking $(basename "${concept_exercise_dir}") exercise..." + # TODO: run command to verify that the exemplar solution passes the tests + fi + done # Verify the Practice Exercises +exit_code=0 + for practice_exercise_dir in ./exercises/practice/*/; do if [ -d $practice_exercise_dir ]; then echo "Checking $(basename "${practice_exercise_dir}") exercise..." - # TODO: run command to verify that the example solution passes the tests + printf '{"version":1,"status":"pass"}' > $(realpath "${practice_exercise_dir}")/expected_results.json + results_file_path="$(realpath "${practice_exercise_dir}")/results.json" + expected_results_file_path="$(realpath "${practice_exercise_dir}")/expected_results.json" + cp $(realpath "${practice_exercise_dir}")/.meta/*.clas.abap $(realpath "${practice_exercise_dir}") + 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" + errors="$(diff "${results_file_path}" "${expected_results_file_path}")" + printf "$errors" + + if [ -z ${errors+x} ]; + then echo "No Erros"; + else exit_code=1; + fi fi done + +exit ${exit_code}