Skip to content
Merged
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
49 changes: 49 additions & 0 deletions bin/test-local-gdscript-solution.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
set -e

# Script for testing a student's local solution to a single GDScript exercise.
#
# This script is intended to be run from any exercise subdirectory from the
# Exercism GDScript track, but can live one directory higher than the
# exercise subdirectories for convenience.

slug=$(basename "$(pwd)")
missing_gd_msg="Normally, the exercise subdirectory created by the exercism download command should contain this file."
general_help_msg="Please see https://exercism.org/docs/tracks/gdscript/installation for details."
if [ ! -f "${slug//-/_}_test.gd" ]; then
echo "Missing test file: ${slug//-/_}_test.gd"
echo $missing_gd_msg
echo $general_help_msg
exit 1
fi
if [ ! -f "${slug//-/_}.gd" ]; then
echo "Missing solution file: ${slug//-/_}.gd"
echo $missing_gd_msg
echo $general_help_msg
exit 1
fi
if [ ! -f "/opt/exercism/gdscript/test-runner/bin/run.sh" ]; then
echo "Missing test runner file: /opt/exercism/gdscript/test-runner/bin/run.sh"
echo $general_help_msg
exit 1
fi

solution_dir="$(pwd)"
output_dir="${solution_dir}/.test-output"
results_file="${output_dir}/results.json"
mkdir -p "${output_dir}"

(cd /opt/exercism/gdscript/test-runner && bin/run.sh "$slug" "$solution_dir" "$output_dir") || {
echo "Test runner script failed."
exit 1
}

test_status="$(jq -r '.status' "${results_file}")"
if [ "$test_status" != "pass" ]; then
echo "Tests for $slug have failed:"
cat "${results_file}"
exit 1
else
echo
echo "Tests for $slug passed!"
fi