forked from neomake/neomake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
169 lines (138 loc) · 5.58 KB
/
Makefile
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
# 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:=$(abspath $(firstword $(wildcard tests/vim/plugins/vader.override) $(DEFAULT_VADER_DIR)))
$(TESTS_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
# 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:=| sed -e 's/^ \+([ [:digit:]]\+\/[[:digit:]]\+) \[[ [:alpha:]]\+\] (X).*/[31m[1m\0[0m/' \
-e 's/^ \+([ [:digit:]]\+\/[[:digit:]]\+)/[1m\0[0m/' \
-e 's/^ \+> \[\(debug\)\] \[[.[:digit:]]\+\]: .*/[38;5;8m\0[0m/' \
-e '/\[\(verb \|quiet\|error\)\]/! s/^ \+> .*/[33;1m\0[0m/'
# 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: _run_interactive
testnvim_interactive: TEST_VIM:=nvim
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='$@'
.PHONY: $(_TESTS_REL_AND_ABS)
tags:
ctags -R --langmap=vim:+.vader
# Linters, called from .travis.yml.
LINT_FILES:=./plugin ./autoload
build/vint: | build
virtualenv $@
$@/bin/pip install vim-vint
vint: build/vint
build/vint/bin/vint $(LINT_FILES)
vint-errors: build/vint
build/vint/bin/vint --error $(LINT_FILES)
# 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_FILES)
vimlint-errors: build/vimlint build/vimlparser
build/vimlint/bin/vimlint.sh -E -l build/vimlint -p build/vimlparser $(LINT_FILES)
build build/neovim-test-home:
mkdir $@
build/neovim-test-home: | build
build/vim-vimhelplint-master: | build
cd build \
&& wget -O- https://github.com/machakann/vim-vimhelplint/archive/master.tar.gz \
| tar xz
vimhelplint: VIMHELPLINT_VIM:=vim
vimhelplint: | build/vim-vimhelplint-master
out="$$($(VIMHELPLINT_VIM) -esN -c 'e doc/neomake.txt' -c 'set ft=help' \
-c 'source build/vim-vimhelplint-master/ftplugin/help_lint.vim' \
-c 'verb VimhelpLintEcho' -c q 2>&1)"; \
if [ -n "$$out" ]; then \
echo "$$out"; \
exit 1; \
fi
docker_vimhelplint:
$(MAKE) docker_make "DOCKER_MAKE_TARGET=vimhelplint \
VIMHELPLINT_VIM=/vim-build/bin/vim-master"
docker_make: DOCKER_RUN=make -C /testplugin $(DOCKER_MAKE_TARGET)
docker_make: docker_run
# Run tests in dockerized Vims.
DOCKER_IMAGE:=neomake/vims-for-tests
DOCKER_STREAMS:=-ti
DOCKER=docker run $(DOCKER_STREAMS) --rm \
-v $(PWD):/testplugin -v $(PWD)/tests/vim:/home $(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:=$(DEFAULT_VADER_DIR)
docker_run: $(DEFAULT_VADER_DIR)
docker_run:
$(DOCKER) $(if $(DOCKER_RUN),$(DOCKER_RUN),bash)
.PHONY: vint vint-errors vimlint vimlint-errors
.PHONY: test testnvim testvim testnvim_interactive testvim_interactive
.PHONY: runvim runnvim tags _run_tests