Skip to content

Commit ae5399a

Browse files
authored
Decouple test CI from test runner (#375)
* Move test CI off test runner image * Remove now-redundant vader install step
1 parent 0fadb69 commit ae5399a

2 files changed

Lines changed: 43 additions & 14 deletions

File tree

.github/workflows/test.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ on:
99
jobs:
1010
ci:
1111
runs-on: ubuntu-24.04
12-
container:
13-
image: exercism/vimscript-test-runner
14-
1512
steps:
1613
- name: Checkout repository
1714
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd

bin/verify-exercises

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,55 @@
22

33
temp_dir_base=$(mktemp -d)
44

5+
echo "Cloning vader.vim to temporary directory"
6+
VADER_TEMP_DIR=$(mktemp -d)
7+
trap "rm -rf '$VADER_TEMP_DIR'" EXIT
8+
9+
git clone --depth 1 https://github.com/junegunn/vader.vim.git "$VADER_TEMP_DIR/vader.vim" > /dev/null 2>&1
10+
VADER_PATH="$VADER_TEMP_DIR/vader.vim"
11+
512
run_test() {
6-
slug=$(basename $1)
13+
slug=${1%/}
14+
slug=${slug##*/}
715
temp_dir=${temp_dir_base}/${slug}
816
mkdir -p ${temp_dir}
917

1018
cp -r "$1/." $temp_dir
11-
slug_snakecase=$(echo "$slug" | tr '-' '_')
12-
cp $temp_dir/.meta/example.vim $temp_dir/$slug_snakecase.vim
13-
14-
(cd /opt/test-runner && bin/run.sh $slug $temp_dir $temp_dir) || exit 1
15-
16-
test_status="$(jq -r '.status' $temp_dir/results.json)"
19+
slug_file=${slug//-/_}
20+
21+
if [ -f "$temp_dir/.meta/exemplar.vim" ]; then
22+
cp $temp_dir/.meta/exemplar.vim $temp_dir/$slug_file.vim
23+
elif [ -f "$temp_dir/.meta/example.vim" ]; then
24+
cp $temp_dir/.meta/example.vim $temp_dir/$slug_file.vim
25+
else
26+
echo "ERROR: Missing example/exemplar solution for $slug"
27+
exit 1
28+
fi
29+
30+
echo -n "Running tests for $slug: "
31+
32+
start_time=$(date +%s.%N)
33+
output=$(vim -es -Nu <(cat <<VIMRC
34+
set nocompatible
35+
set backspace=indent,eol,start
36+
set runtimepath+=$VADER_PATH
37+
set runtimepath+=$temp_dir
38+
filetype off
39+
filetype plugin indent on
40+
syntax enable
41+
VIMRC
42+
) -c "source $temp_dir/$slug_file.vim" -c "Vader! $temp_dir/$slug_file.vader" 2>&1)
1743

18-
if [ "$test_status" != "pass" ]; then
19-
echo "Tests for $slug have failed:"
20-
cat $temp_dir/results.json
21-
exit 1
44+
exit_code=$?
45+
end_time=$(date +%s.%N)
46+
duration=$(echo "$end_time - $start_time" | bc)
47+
48+
if [ $exit_code -ne 0 ]; then
49+
echo "FAILED!"
50+
echo "$output" | sed -n '/^Starting Vader:/,$p'
51+
exit 1
52+
else
53+
printf "ok (%.2fs)\n" "$duration"
2254
fi
2355
}
2456

0 commit comments

Comments
 (0)