diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 39f0f80..5ecd543 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,9 +9,6 @@ on: jobs: ci: runs-on: ubuntu-24.04 - container: - image: exercism/vimscript-test-runner - steps: - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd diff --git a/bin/verify-exercises b/bin/verify-exercises index b10a541..d90ca3d 100755 --- a/bin/verify-exercises +++ b/bin/verify-exercises @@ -2,23 +2,55 @@ temp_dir_base=$(mktemp -d) +echo "Cloning vader.vim to temporary directory" +VADER_TEMP_DIR=$(mktemp -d) +trap "rm -rf '$VADER_TEMP_DIR'" EXIT + +git clone --depth 1 https://github.com/junegunn/vader.vim.git "$VADER_TEMP_DIR/vader.vim" > /dev/null 2>&1 +VADER_PATH="$VADER_TEMP_DIR/vader.vim" + run_test() { - slug=$(basename $1) + slug=${1%/} + slug=${slug##*/} temp_dir=${temp_dir_base}/${slug} mkdir -p ${temp_dir} cp -r "$1/." $temp_dir - slug_snakecase=$(echo "$slug" | tr '-' '_') - cp $temp_dir/.meta/example.vim $temp_dir/$slug_snakecase.vim - - (cd /opt/test-runner && bin/run.sh $slug $temp_dir $temp_dir) || exit 1 - - test_status="$(jq -r '.status' $temp_dir/results.json)" + slug_file=${slug//-/_} + + if [ -f "$temp_dir/.meta/exemplar.vim" ]; then + cp $temp_dir/.meta/exemplar.vim $temp_dir/$slug_file.vim + elif [ -f "$temp_dir/.meta/example.vim" ]; then + cp $temp_dir/.meta/example.vim $temp_dir/$slug_file.vim + else + echo "ERROR: Missing example/exemplar solution for $slug" + exit 1 + fi + + echo -n "Running tests for $slug: " + + start_time=$(date +%s.%N) + output=$(vim -es -Nu <(cat <&1) - if [ "$test_status" != "pass" ]; then - echo "Tests for $slug have failed:" - cat $temp_dir/results.json - exit 1 + exit_code=$? + end_time=$(date +%s.%N) + duration=$(echo "$end_time - $start_time" | bc) + + if [ $exit_code -ne 0 ]; then + echo "FAILED!" + echo "$output" | sed -n '/^Starting Vader:/,$p' + exit 1 + else + printf "ok (%.2fs)\n" "$duration" fi }