forked from neomake/neomake
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
185 lines (152 loc) · 5.97 KB
/
Makefile
File metadata and controls
185 lines (152 loc) · 5.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# Do not let mess "cd" with user-defined paths.
CDPATH:=
test:
$(MAKE) testnvim
$(MAKE) testvim
SHELL:=/bin/bash -o pipefail
VADER:=Vader!
VADER_OPTIONS?=
VADER_ARGS=tests/neomake.vader $(VADER_OPTIONS)
VIM_ARGS='+$(VADER) $(VADER_ARGS)'
DEFAULT_VADER_DIR:=tests/vim/plugins/vader
export TESTS_VADER_DIR:=$(firstword $(realpath $(wildcard tests/vim/plugins/vader.override)) $(DEFAULT_VADER_DIR))
$(DEFAULT_VADER_DIR):
mkdir -p $(dir $@)
git clone --depth=1 https://github.com/junegunn/vader.vim $@
TEST_VIMRC:=tests/vim/vimrc
# This is expected in tests.
TEST_VIM_PREFIX:=SHELL=/bin/bash
testx: export VADER_OPTIONS=-x
testx: test
testnvimx: export VADER_OPTIONS=-x
testnvimx: testnvim
# Neovim might quit after ~5s with stdin being closed. Use --headless mode to
# work around this.
# > Vim: Error reading input, exiting...
# > Vim: Finished.
testnvim: TEST_VIM:=nvim --headless
# Neovim needs a valid HOME (https://github.com/neovim/neovim/issues/5277).
testnvim: build/neovim-test-home
testnvim: TEST_VIM_PREFIX+=HOME=build/neovim-test-home
testnvim: TEST_VIM_PREFIX+=VADER_OUTPUT_FILE=/dev/stderr
testnvim: _run_vim
testvim: TEST_VIM:=vim -X
testvim: TEST_VIM_PREFIX+=HOME=/dev/null
testvim: _run_vim
# Add coloring to Vader's output:
# 1. failures (includes pending) in red "(X)"
# 2. test case header in bold "(2/2)"
# 3. Neomake's debug log messages in less intense grey
# 4. non-Neomake log lines (e.g. from :Log) in bold/bright yellow.
_SED_HIGHLIGHT_ERRORS:=| contrib/highlight-log vader
# Need to close stdin to fix spurious 'sed: couldn't write X items to stdout: Resource temporarily unavailable'.
# Redirect to stderr again for Docker (where only stderr is used from).
_REDIR_STDOUT:=2>&1 </dev/null >/dev/null $(_SED_HIGHLIGHT_ERRORS) >&2
_run_vim: | build $(TESTS_VADER_DIR)
_run_vim:
@echo $(TEST_VIM_PREFIX) $(TEST_VIM) -u $(TEST_VIMRC) -i NONE $(VIM_ARGS)
@$(TEST_VIM_PREFIX) $(TEST_VIM) -u $(TEST_VIMRC) -i NONE $(VIM_ARGS) $(_REDIR_STDOUT)
# Interactive tests, keep Vader open.
_run_interactive: VADER:=Vader
_run_interactive: _REDIR_STDOUT:=
_run_interactive: _run_vim
testvim_interactive: TEST_VIM:=vim -X
testvim_interactive: TEST_VIM_PREFIX+=HOME=/dev/null
testvim_interactive: _run_interactive
testnvim_interactive: TEST_VIM:=nvim
testnvim_interactive: TEST_VIM_PREFIX+=HOME=build/neovim-test-home
testnvim_interactive: _run_interactive
# Manually invoke Vim, using the test setup. This helps with building tests.
runvim: VIM_ARGS:=
runvim: testvim_interactive
runnvim: VIM_ARGS:=
runnvim: testnvim_interactive
TEST_TARGET:=test
# Add targets for .vader files, absolute and relative.
# This can be used with `b:dispatch = ':Make %'` in Vim.
TESTS:=$(wildcard tests/*.vader tests/*/*.vader)
uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
_TESTS_REL_AND_ABS:=$(call uniq,$(abspath $(TESTS)) $(TESTS))
$(_TESTS_REL_AND_ABS):
make $(TEST_TARGET) VADER_ARGS='$@ $(VADER_OPTIONS)'
.PHONY: $(_TESTS_REL_AND_ABS)
tags:
ctags -R --langmap=vim:+.vader
# Linters, called from .travis.yml.
LINT_ARGS:=./plugin ./autoload
build/vint: | build
virtualenv $@
$@/bin/pip install vim-vint
vint: build/vint
build/vint/bin/vint $(LINT_ARGS)
vint-errors: build/vint
build/vint/bin/vint --error $(LINT_ARGS)
# vimlint
build/vimlint: | build
git clone --depth=1 https://github.com/syngan/vim-vimlint $@
build/vimlparser: | build
git clone --depth=1 https://github.com/ynkdir/vim-vimlparser $@
vimlint: build/vimlint build/vimlparser
build/vimlint/bin/vimlint.sh -l build/vimlint -p build/vimlparser $(LINT_ARGS)
vimlint-errors: build/vimlint build/vimlparser
build/vimlint/bin/vimlint.sh -E -l build/vimlint -p build/vimlparser $(LINT_ARGS)
build build/neovim-test-home:
mkdir $@
build/neovim-test-home: | build
build/vimhelplint: | build
cd build \
&& wget -O- https://github.com/machakann/vim-vimhelplint/archive/master.tar.gz \
| tar xz \
&& mv vim-vimhelplint-master vimhelplint
vimhelplint: export VIMHELPLINT_VIM:=vim
vimhelplint: | build/vimhelplint
contrib/vimhelplint doc/neomake.txt
# Run tests in dockerized Vims.
DOCKER_IMAGE:=neomake/vims-for-tests
DOCKER_STREAMS:=-ti
DOCKER=docker run $(DOCKER_STREAMS) --rm \
-v $(PWD):/testplugin -v $(abspath $(TESTS_VADER_DIR)):/home/plugins/vader $(DOCKER_IMAGE)
docker_image:
docker build -f Dockerfile.tests -t $(DOCKER_IMAGE) .
docker_push:
docker push $(DOCKER_IMAGE)
# docker run --rm $(DOCKER_IMAGE) sh -c 'cd /vim-build/bin && ls vim*'
DOCKER_VIMS:=vim73 vim74-trusty vim74-xenial vim8069 vim-master
_DOCKER_VIM_TARGETS:=$(addprefix docker_test-,$(DOCKER_VIMS))
docker_test_all: $(_DOCKER_VIM_TARGETS)
$(_DOCKER_VIM_TARGETS):
$(MAKE) docker_test DOCKER_VIM=$(patsubst docker_test-%,%,$@)
docker_test: DOCKER_VIM:=vim-master
docker_test: DOCKER_STREAMS:=-a stderr
docker_test: DOCKER_MAKE_TARGET:=testvim TEST_VIM=/vim-build/bin/$(DOCKER_VIM) VIM_ARGS="$(VIM_ARGS)"
docker_test: docker_make
docker_run: $(TESTS_VADER_DIR)
docker_run:
$(DOCKER) $(if $(DOCKER_RUN),$(DOCKER_RUN),bash)
docker_make: DOCKER_RUN=make -C /testplugin $(DOCKER_MAKE_TARGET)
docker_make: docker_run
docker_vimhelplint:
$(MAKE) docker_make "DOCKER_MAKE_TARGET=vimhelplint \
VIMHELPLINT_VIM=/vim-build/bin/vim-master"
check:
@:; ret=0; \
echo '== Checking that all tests are included'; \
for f in $(filter-out neomake.vader,$(notdir $(shell git ls-files tests/*.vader))); do \
if ! grep -q "^Include.*: $$f" tests/neomake.vader; then \
echo "Test not included: $$f" >&2; ret=1; \
fi; \
done; \
echo '== Checking for absent Before sections in tests'; \
if grep '^Before:' tests/*.vader; then \
echo "Before: should not be used in tests itself, because it overrides the global one."; \
(( ret+=2 )); \
fi; \
echo '== Checking for absent :Log calls'; \
if grep '^\s*Log\b' $(shell git ls-files tests/*.vader $(LINT_ARGS)); then \
echo "Found Log commands."; \
(( ret+=4 )); \
fi; \
exit $$ret
.PHONY: vint vint-errors vimlint vimlint-errors
.PHONY: test testnvim testvim testnvim_interactive testvim_interactive
.PHONY: runvim runnvim tags _run_tests