verify tool working. test.sno changed to suit.#38
Conversation
|
This PR touches files which potentially affect the outcome of the tests of an exercise. This will cause all students' solutions to affected exercises to be re-tested. If this PR does not affect the result of the test (or, for example, adds an edge case that is not worth rerunning all tests for), please add the following to the merge-commit message which will stops student's tests from re-running. Please copy-paste to avoid typos. For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping |
| echo "Checking $(basename "${practice_exercise_dir}") exercise..." | ||
| # TODO: run command to verify that the example solution passes the tests | ||
| for dir in ./exercises/practice/*/; do | ||
| if [ -d $dir ]; then |
There was a problem hiding this comment.
| if [ -d $dir ]; then | |
| if [[ -d $dir ]]; then |
If you negate this test, you can unnest the rest of the block.
If you set -o nullglob first, this test shouldn't be needed as this loop will only run with a directory path.
| # TODO: run command to verify that the example solution passes the tests | ||
| for dir in ./exercises/practice/*/; do | ||
| if [ -d $dir ]; then | ||
| slug=$(basename "${dir}") |
There was a problem hiding this comment.
| slug=$(basename "${dir}") | |
| slug="${dir##*/}" |
| for dir in ./exercises/practice/*/; do | ||
| if [ -d $dir ]; then | ||
| slug=$(basename "${dir}") | ||
| echo $slug |
There was a problem hiding this comment.
Unquoted expansion. You could also make this a bit more informative.
| echo $slug | |
| printf 'Testing practice exercise %\n' "$slug" |
| if [ -d $dir ]; then | ||
| slug=$(basename "${dir}") | ||
| echo $slug | ||
| cd "${dir}" |
There was a problem hiding this comment.
| cd "${dir}" | |
| cd "${dir}" || exit |
| slug=$(basename "${dir}") | ||
| echo $slug | ||
| cd "${dir}" | ||
| mv "${slug}.sno" "${slug}.aside" |
There was a problem hiding this comment.
Consider using a tempdir for temp files.
| cp ".meta/example.sno" "${slug}.sno" | ||
| snobol4 test.sno | ||
| errcode=$? | ||
| mv "${slug}.aside" "${slug}.sno" |
There was a problem hiding this comment.
You could use a subshell to handle the undo-cd and a trap to handle this cleanup. That would tidy things up.
You can also report on all the failing tests vs the first failure.
tmpdir=$(mktemp -d)
set -o nullglob
failed=()
for dir in ./exercises/practice/*/; do
slug="${dir##*/}"
(
cd "$slug" || exit
cleanup () { mv "$tmpdir/$slug.sno" ./; }
trap cleanup EXIT
mv "$slug.sno" "$tmpdir"
cp ".meta/example.sno" "$slug.sno"
snobol4 test.sno
) || failed+=("$slug")
done
if (( ${#failed[@]}" )); then
echo "Some practice tests failed:"
printf '* %s\n' "${failed[@]}"
exit 1
fi| errcode=$? | ||
| mv "${slug}.aside" "${slug}.sno" | ||
| cd - > /dev/null | ||
| if [ $errcode -ne 0 ]; then |
There was a problem hiding this comment.
| if [ $errcode -ne 0 ]; then | |
| if (( errcode != 0 )); then |
No description provided.