Browse Source

Make it work with non-executable scripts

content-update
xpetit 3 years ago
parent
commit
dd0b515691
No known key found for this signature in database
GPG Key ID: 97C60669182C17A5
  1. 4
      sh/tests/cl-camp1_test.sh
  2. 4
      sh/tests/cl-camp3_test.sh
  3. 4
      sh/tests/cl-camp4_test.sh
  4. 4
      sh/tests/cl-camp5_test.sh
  5. 4
      sh/tests/cl-camp6_test.sh
  6. 4
      sh/tests/cl-camp8_test.sh
  7. 4
      sh/tests/explain_test.sh
  8. 4
      sh/tests/now-get-to-work_test.sh
  9. 5
      sh/tests/teacher_test.sh

4
sh/tests/cl-camp1_test.sh

@ -8,8 +8,8 @@ IFS='
script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd) script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd)
challenge() { challenge() {
submitted=$(cd "$1" && "$script_dirS"/student/mastertheLS) submitted=$(cd "$1" && bash "$script_dirS"/student/mastertheLS)
expected=$(cd "$1" && "$script_dirS"/solutions/mastertheLS) expected=$(cd "$1" && bash "$script_dirS"/solutions/mastertheLS)
diff <(echo "$submitted") <(echo "$expected") diff <(echo "$submitted") <(echo "$expected")
} }

4
sh/tests/cl-camp3_test.sh

@ -8,8 +8,8 @@ IFS='
script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd) script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd)
challenge() { challenge() {
submitted=$(cd "$1" && "$script_dirS"/student/look) submitted=$(cd "$1" && bash "$script_dirS"/student/look)
expected=$(cd "$1" && "$script_dirS"/solutions/look) expected=$(cd "$1" && bash "$script_dirS"/solutions/look)
diff <(echo "$submitted") <(echo "$expected") diff <(echo "$submitted") <(echo "$expected")
} }

4
sh/tests/cl-camp4_test.sh

@ -9,8 +9,8 @@ echo insecure >> ~/.curlrc
caddy start &>/dev/null caddy start &>/dev/null
challenge() { challenge() {
submitted=$(./student/myfamily.sh) submitted=$(bash student/myfamily.sh)
expected=$(./solutions/myfamily.sh) expected=$(bash solutions/myfamily.sh)
diff <(echo "$submitted") <(echo "$expected") diff <(echo "$submitted") <(echo "$expected")
} }

4
sh/tests/cl-camp5_test.sh

@ -8,8 +8,8 @@ IFS='
script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd) script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd)
challenge() { challenge() {
submitted=$(cd "$1" && "$script_dirS"/student/lookagain.sh) submitted=$(cd "$1" && bash "$script_dirS"/student/lookagain.sh)
expected=$(cd "$1" && "$script_dirS"/solutions/lookagain.sh) expected=$(cd "$1" && bash "$script_dirS"/solutions/lookagain.sh)
diff <(echo "$submitted") <(echo "$expected") diff <(echo "$submitted") <(echo "$expected")
} }

4
sh/tests/cl-camp6_test.sh

@ -8,8 +8,8 @@ IFS='
script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd) script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd)
challenge() { challenge() {
submitted=$(cd "$1" && "$script_dirS"/student/countfiles.sh) submitted=$(cd "$1" && bash "$script_dirS"/student/countfiles.sh)
expected=$(cd "$1" && "$script_dirS"/solutions/countfiles.sh) expected=$(cd "$1" && bash "$script_dirS"/solutions/countfiles.sh)
diff <(echo "$submitted") <(echo "$expected") diff <(echo "$submitted") <(echo "$expected")
} }

4
sh/tests/cl-camp8_test.sh

@ -7,7 +7,7 @@ IFS='
cd cl-camp8 cd cl-camp8
submitted=$(../student/skip.sh) submitted=$(bash ../student/skip.sh)
expected=$(../solutions/skip.sh) expected=$(bash ../solutions/skip.sh)
diff <(echo "$submitted") <(echo "$expected") diff <(echo "$submitted") <(echo "$expected")

4
sh/tests/explain_test.sh

@ -5,8 +5,8 @@ set -euo pipefail
IFS=' IFS='
' '
submitted=$(student/explain.sh) submitted=$(bash student/explain.sh)
expected=$(solutions/explain.sh) expected=$(bash solutions/explain.sh)
if ! diff -q <(echo "$submitted") <(echo "$expected") &>/dev/null; then if ! diff -q <(echo "$submitted") <(echo "$expected") &>/dev/null; then
echo "Wrong answer, detective." echo "Wrong answer, detective."

4
sh/tests/now-get-to-work_test.sh

@ -5,8 +5,8 @@ set -euo pipefail
IFS=' IFS='
' '
submitted=$(student/my_answer.sh) submitted=$(bash student/my_answer.sh)
expected=$(solutions/my_answer.sh) expected=$(bash solutions/my_answer.sh)
if ! diff -q <(echo "$submitted") <(echo "$expected") &>/dev/null; then if ! diff -q <(echo "$submitted") <(echo "$expected") &>/dev/null; then
echo "Wrong answer, detective." echo "Wrong answer, detective."

5
sh/tests/teacher_test.sh

@ -7,10 +7,9 @@ IFS='
script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd) script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd)
challenge() { challenge() {
submitted=$(cd "$1" && "$script_dirS"/student/teacher.sh) || (echo "Your script exited with a non-zero status code"; exit 1) submitted=$(cd "$1" && bash "$script_dirS"/student/teacher.sh) || (echo "Your script exited with a non-zero status code"; exit 1)
expected=$(cd "$1" && "$script_dirS"/solutions/teacher.sh) expected=$(cd "$1" && bash "$script_dirS"/solutions/teacher.sh)
if ! diff -q <(echo "$submitted") <(echo "$expected") &>/dev/null; then if ! diff -q <(echo "$submitted") <(echo "$expected") &>/dev/null; then
echo "??? What ?? Wrong answer, teacher. Did you really do the job previously? Or was is just an \"echo\" of luck??" echo "??? What ?? Wrong answer, teacher. Did you really do the job previously? Or was is just an \"echo\" of luck??"

Loading…
Cancel
Save