Skip to content

Commit e5f86af

Browse files
committed
New indentation test runner
1 parent 8e9ed28 commit e5f86af

File tree

48 files changed

+121
-97
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+121
-97
lines changed

.github/workflows/indent.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Indent
2+
on:
3+
push:
4+
branches: [ master ]
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
vim-latest:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Fetch source
13+
uses: actions/checkout@v3
14+
- name: Install Vim
15+
uses: rhysd/action-setup-vim@v1
16+
with: { version: stable }
17+
- name: Run indentation tests
18+
run: EDITOR=vim do/test-indent
19+
working-directory: ./dev
20+
21+
neovim-latest:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Fetch source
25+
uses: actions/checkout@v3
26+
- name: Install Neovim
27+
uses: rhysd/action-setup-vim@v1
28+
with: { neovim: true, version: stable }
29+
- name: Run indentation tests
30+
run: EDITOR=nvim do/test-indent
31+
working-directory: ./dev

.github/workflows/clojure.yml .github/workflows/syntax.yml

+1-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: Syntax
22
on:
33
push:
44
branches:
@@ -29,17 +29,6 @@ jobs:
2929
with:
3030
lein: 2.11.2
3131

32-
- name: Install Vim
33-
uses: rhysd/action-setup-vim@v1
34-
with:
35-
version: stable
36-
37-
- name: Install Neovim
38-
uses: rhysd/action-setup-vim@v1
39-
with:
40-
neovim: true
41-
version: stable
42-
4332
- name: Cache m2
4433
uses: actions/cache@v3
4534
env:

clj/resources/indent-test-cases/multi-line_strings_pretty/config.edn

-4
This file was deleted.

clj/resources/indent-test-cases/multi-line_strings_standard/config.edn

-4
This file was deleted.

clj/resources/indent-test-cases/multi-line_strings_traditional/config.edn

-4
This file was deleted.

clj/resources/indent-test-cases/s-expr_standard/config.edn

-1
This file was deleted.

clj/resources/indent-test-cases/s-expr_traditional/config.edn

-1
This file was deleted.

clj/resources/indent-test-cases/s-expr_uniform/config.edn

-1
This file was deleted.

clj/test/vim/helpers.clj

-21
This file was deleted.

clj/test/vim/indent_test.clj

-49
This file was deleted.

dev/do/test-indent

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env bash
2+
3+
# Run Clojure.vim indentation tests
4+
5+
# TODO: colour messages?
6+
7+
if [ "$EDITOR" != 'vim' ] && [ "$EDITOR" != 'nvim' ]; then
8+
echo 'ERROR: Set the "EDITOR" environment variable to "vim" or "nvim" and run again.'
9+
exit 1
10+
fi
11+
12+
PASSED=()
13+
FAILED=()
14+
SKIPPED=()
15+
16+
tmp_base_dir='/tmp/clojure.vim/indent'
17+
mkdir -p "$tmp_base_dir"
18+
tmp_dir="$(mktemp --directory "$tmp_base_dir/XXXXXX")"
19+
test_case_dir='tests'
20+
21+
test_pass() { PASSED+=("$1"); }
22+
test_fail() {
23+
FAILED+=("$1")
24+
echo "::error file=clj/indent-test/$test_case_dir/$1/out.clj::Failed indent test case."
25+
}
26+
test_skip() {
27+
SKIPPED+=("$1")
28+
echo "::warning file=clj/indent-test/$test_case_dir/$1/out.clj::Skipped indent test case."
29+
}
30+
31+
run_test_case() {
32+
test_case="$1"
33+
in_file="$test_case_dir/$test_case/in.clj"
34+
expected_file="$test_case_dir/$test_case/out.clj"
35+
36+
echo "::group::$EDITOR -- $test_case"
37+
38+
if [ -f "$test_case_dir/$test_case/SKIP" ]; then
39+
test_skip "$test_case"
40+
else
41+
actual_file="$tmp_dir/$test_case.clj"
42+
cp "$in_file" "$actual_file"
43+
44+
# Override the default test commands with a `test.vim` file.
45+
test_script="$test_case_dir/$test_case/test.vim"
46+
if [ -f "$test_script" ]; then
47+
test_cmd=('-S' "$test_script")
48+
else
49+
test_cmd=('+normal! gg=G')
50+
fi
51+
52+
"$EDITOR" --clean -NXnu test-vimrc.vim "${test_cmd[@]}" '+xall!' -- "$actual_file"
53+
54+
diff --color=always -u "$expected_file" "$actual_file"
55+
56+
[ $? -eq 0 ] && test_pass "$test_case" || test_fail "$test_case"
57+
fi
58+
59+
echo '::endgroup::'
60+
}
61+
62+
for tcase in $test_case_dir/*/; do
63+
run_test_case "$(basename "$tcase")"
64+
done
65+
66+
echo "passed: ${#PASSED[@]}, failed: ${#FAILED[@]}, skipped: ${#SKIPPED[@]}"
67+
exit ${#FAILED[@]}

dev/test-vimrc.vim

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let &rtp = getcwd() . '/..,' . &rtp
2+
filetype plugin indent on
3+
syntax enable
File renamed without changes.
File renamed without changes.

dev/tests/custom_types/SKIP

Whitespace-only changes.
File renamed without changes.
File renamed without changes.

dev/tests/letfn/SKIP

Whitespace-only changes.
File renamed without changes.
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
let g:clojure_indent_multiline_strings = 'pretty'
2+
normal! gg=G
3+
normal! G
4+
exec "normal! o\<CR>test \"hello\<CR>world\""
5+
exec "normal! o\<CR>regex #\"asdf\<CR>bar\""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
let g:clojure_indent_multiline_strings = 'standard'
2+
normal! gg=G
3+
normal! G
4+
exec "normal! o\<CR>test \"hello\<CR>world\""
5+
exec "normal! o\<CR>regex #\"asdf\<CR>bar\""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
let g:clojure_indent_multiline_strings = 'traditional'
2+
normal! gg=G
3+
normal! G
4+
exec "normal! o\<CR>test \"hello\<CR>world\""
5+
exec "normal! o\<CR>regex #\"asdf\<CR>bar\""
File renamed without changes.
File renamed without changes.

dev/tests/reader_conditionals/SKIP

Whitespace-only changes.

dev/tests/s-expr_traditional/test.vim

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
let g:clojure_indent_style = 'traditional'
2+
normal! gg=G

dev/tests/s-expr_uniform/test.vim

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
let g:clojure_indent_style = 'uniform'
2+
normal! gg=G
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)