Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script to verify exercises #17

Merged
merged 1 commit into from
May 24, 2024
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
34 changes: 25 additions & 9 deletions bin/verify-exercises
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,35 @@
# ./bin/verify-exercises two-fer

slug="${1:-*}"
test_dir=$(mktemp -d)

# Verify the Concept Exercises
for concept_exercise_dir in ./exercises/concept/${slug}/; 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
cleanup() { rm -rf "$test_dir"; }
trap cleanup EXIT

function verify_exercise() {
local dir="${1}"
local slug=$(basename "${dir}")
local tmp_dir="${test_dir}/${slug}"

cp -r "${dir}" "${tmp_dir}"
cd "${tmp_dir}"

sed -i 's/test.skip/test/g' "tests/test-${slug}.art"
cp ".meta/src/example.art" "src/${slug}.art"

arturo tester.art
}

exit_code=0

# Verify the Practice Exercises
for practice_exercise_dir in ./exercises/practice/${slug}/; 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
verify_exercise "${practice_exercise_dir}"
if (( $? != 0 )); then
exit_code=1
fi
fi
done

exit $exit_code