From c3e5f12275fe1f591d24de5e409870c73b635caa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franc=CC=A7ois=20Pottier?= Date: Fri, 11 Sep 2020 18:57:54 +0200 Subject: [PATCH] Fix problems reported by shellcheck in test.sh. --- exercises/lib/test.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/exercises/lib/test.sh b/exercises/lib/test.sh index d68e3e3..e7dc00d 100755 --- a/exercises/lib/test.sh +++ b/exercises/lib/test.sh @@ -6,39 +6,39 @@ IFS=$'\n\t' grade() { local f="$1" - $LEARN grade --timeout=5 --grade-student=$f --dump-reports=${f%.ml} >${f%.ml}.log 2>&1 + $LEARN grade --timeout=5 --grade-student="$f" --dump-reports="${f%.ml}" >"${f%.ml}.log" 2>&1 } export -f grade filter() { local f="$1" - rm -f $.bak - mv $f $f.bak - grep -v "Learnocaml v" $f.bak >$f - rm -f $f.bak + rm -f "$f.bak" + mv "$f" "$f.bak" + grep -v "Learnocaml v" "$f.bak" >"$f" + rm -f "$f.bak" } export -f filter positive_test() { local f="$1" - if grade $f ; then + if grade "$f" ; then echo " [OK] $f is correctly accepted." ; else echo "[FAIL] $f is rejected!" ; fi - filter ${f%.ml}.log + filter "${f%.ml}.log" } export -f positive_test negative_test() { local f="$1" - rm -f ${f%.ml}.report.txt ${f%.ml}.report.html ; - if grade $f ; then + rm -f "${f%.ml}.report.txt" "${f%.ml}.report.html" ; + if grade "$f" ; then echo "[FAIL] $f is incorrectly accepted!" ; else echo " [OK] $f is correctly rejected." ; fi - filter ${f%.ml}.log + filter "${f%.ml}.log" } export -f negative_test @@ -49,12 +49,12 @@ time -p positive_test solution.ml # Allow other correct solutions to be proposed. if [ -d right ] ; then echo "Grading known correct solutions..." - time -p (ls right/*.ml | parallel --no-notice positive_test) ; + time -p (find . -maxdepth 1 -name "right/*.ml" | parallel --no-notice positive_test) ; fi # Make sure that a number of known incorrect solutions are rejected. echo "Grading known incorrect solutions..." -time -p (ls wrong/*.ml | parallel --no-notice negative_test) +time -p (find . -maxdepth 1 -name "wrong/*.ml" | parallel --no-notice negative_test) # Use git status to display any differences with respect to the expected # output and expected log (which should be checked in).