Skip to content

Commit 9a93dd6

Browse files
committed
1 parent e39f11e commit 9a93dd6

File tree

5 files changed

+43
-47
lines changed

5 files changed

+43
-47
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
include:
11+
- vim-url: https://github.com/vim/vim-appimage/releases/download/v8.2.2282/GVim-v8.2.2282.glibc2.15-x86_64.AppImage
12+
vim-flags: --not-a-term
13+
- vim-url: https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage
14+
vim-flags: --headless
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Install Vim
18+
run: |
19+
curl -L --output vim ${{ matrix.vim-url }}
20+
chmod +x vim
21+
- name: Run tests
22+
run: make test VIM=./vim VIMFLAGS=${{ matrix.vim-flags }}

Makefile

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
VIM = vim
1+
VIM := vim
2+
unexport VIM
3+
VIMFLAGS := $(if $(filter nvim,$(VIM)),--headless,--not-a-term)
24

3-
ifeq ($(VIM),vim)
4-
args = --not-a-term
5-
else ifeq ($(VIM),nvim)
6-
args = --headless
7-
endif
5+
all: test
86

9-
all: check
7+
TESTS := $(wildcard test/test*.vim)
108

11-
check:
12-
$(foreach test,$(wildcard test/*.vim),$(VIM) --clean $(args) -u runtest.vim "$(test)")
9+
$(TESTS):
10+
$(VIM) --clean $(VIMFLAGS) -u runtest.vim "$@"
1311

14-
.PHONY: all check
12+
test: $(TESTS)
13+
14+
.PHONY: all test $(TESTS)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# vim-strip-trailing-whitespace
2-
![](https://github.com/axelf4/vim-strip-trailing-whitespace/workflows/CI/badge.svg)
2+
![](https://github.com/axelf4/vim-strip-trailing-whitespace/workflows/test/badge.svg)
33

44
Vim plugin that removes trailing whitespace
55
* **from modified lines:** Should not introduce extraneous changes into the diff, even when editing faulty files.

runtest.vim

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,24 @@ try
66
source plugin/strip_trailing_whitespace.vim
77

88
source %
9-
let s:tests = map(split(execute('function /^Test_'), "\n"), {_, v -> matchstr(v, 'function \zs\k\+\ze()')})
9+
" Query list of functions matching ^Test_
10+
let s:tests = map(split(execute('function /^Test_'), "\n"), 'matchstr(v:val, ''^function \zs\k\+\ze()'')')
11+
1012
for s:test_function in s:tests
1113
let v:errors = []
1214
echo 'Test' s:test_function
1315
try
1416
execute 'call' s:test_function '()'
1517
catch
1618
call add(v:errors, "Uncaught exception in test: " .. v:exception .. " at " .. v:throwpoint)
17-
finally
18-
if !empty(v:errors)
19-
echo s:testfile .. ':1:Error'
20-
for s:error in v:errors
21-
echo s:error
22-
endfor
23-
let s:has_errors = 1
24-
endif
2519
endtry
20+
if !empty(v:errors)
21+
echo s:testfile .. ':1:Error'
22+
for s:error in v:errors
23+
echo s:error
24+
endfor
25+
let s:has_errors = 1
26+
endif
2627
endfor
2728
catch
2829
echo v:exception

0 commit comments

Comments
 (0)