diff --git a/Dockerfile b/Dockerfile index 195fc0b..f1d2a6b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,7 @@ FROM ubuntu:24.04 # Ubuntu 24.04 ships with bash version 5.2 # https://hub.docker.com/layers/library/ubuntu/24.04/images/sha256-3963c438d67a34318a3672faa6debd1dfff48e5d52de54305988b932c61514ca?context=explore -# Specifically use bats 1.5.0 -# Remove git when we're done with it. +# 24.04 provides bats v1.10.0 # Test runner needs jq. # Other commands to add to environment, might be used by students # - bc @@ -11,17 +10,11 @@ FROM ubuntu:24.04 # Tools commonly used by students that will already be installed include: # - sed, tr, ... -RUN apt-get update && \ - apt-get install -y git jq bc gawk && \ - git clone https://github.com/bats-core/bats-core && \ - cd bats-core && \ - git checkout v1.5.0 && \ - bash ./install.sh /usr/local && \ - cd && \ - apt-get remove -y git && \ - apt-get purge --auto-remove -y && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* ./bats-core +RUN apt-get update && \ + apt-get install -y bats jq bc gawk && \ + apt-get purge --auto-remove -y && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* COPY . /opt/test-runner WORKDIR /opt/test-runner diff --git a/bats b/bats deleted file mode 160000 index c706d14..0000000 --- a/bats +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c706d1470dd1376687776bbe985ac22d09780327 diff --git a/bin/run.sh b/bin/run.sh index 804192e..5ab02ae 100755 --- a/bin/run.sh +++ b/bin/run.sh @@ -18,6 +18,15 @@ INTERFACE_VERSION=2 main() { + if (($# != 3)) || [[ $1 == '-h' ]]; then + echo "usage: $0 " + echo "" + echo "Typically, solution_directory == output_directory" + echo "example:" + echo "\$ $0 one_passing ./tests/data/one_passing{,}" + exit + fi + echo "Running exercise tests for Bash" local slug="$1" @@ -190,7 +199,8 @@ error() { --argjson version "$INTERFACE_VERSION" \ --arg status "error" \ --arg message "$(< "$output_file")" \ - '{version: $version, status: $status, message: $message}' + '{version: $version, status: $status, message: $message}' \ + > "$json_result_file" echo "Wrote error report to $json_result_file" } diff --git a/tests/data/missing_script/expected_results.json b/tests/data/missing_script/expected_results.json index b126064..78d8909 100644 --- a/tests/data/missing_script/expected_results.json +++ b/tests/data/missing_script/expected_results.json @@ -1,12 +1,5 @@ { "version": 2, - "status": "fail", - "tests": [ - { - "name": "say hello", - "status": "fail", - "test_code": "run bash one_passing.sh\n[ \"$status\" -eq 0 ]\n[ \"$output\" == \"Hello, World!\" ]", - "message": "(in test file missing_script.bats, line 5)\n `[ \"$status\" -eq 0 ]' failed\n" - } - ] + "status": "error", + "message": "1..1\nnot ok 1 say hello\n# (in test file missing_script.bats, line 5)\n# `[ \"$status\" -eq 0 ]' failed\n\nThe following warnings were encountered during tests:\nBW01: `run`'s command `bash one_passing.sh` exited with code 127, indicating 'Command not found'. Use run's return code checks, e.g. `run -127`, to fix this message.\n (from function `run' in file /home/linuxbrew/.linuxbrew/Cellar/bats-core/1.11.0/lib/bats-core/test_functions.bash, line 426,\n in test file missing_script.bats, line 4)" } diff --git a/tests/tests.bats b/tests/tests.bats index b3c656c..572ad7f 100644 --- a/tests/tests.bats +++ b/tests/tests.bats @@ -68,7 +68,7 @@ actual_matches_expected() { TEST_DIR="$DATA_DIR/$TEST" run "$RUN_SCRIPT" "$TEST" "$TEST_DIR" "$TEST_DIR" - [[ "$status" -eq 0 ]] + [[ "$status" -ne 0 ]] actual_matches_expected "$TEST_DIR/results.json" "$TEST_DIR/expected_results.json" }