Skip to content

Commit c6f1b84

Browse files
authored
Add support for installing Neovim and other fixes (Vimjas#9)
1 parent 763882c commit c6f1b84

File tree

8 files changed

+299
-100
lines changed

8 files changed

+299
-100
lines changed

Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ RUN adduser -h /home -s /bin/sh -D -u 8465 vimtest
55
RUN mkdir -p /vim /vim-build/bin /plugins
66
RUN chown vimtest:vimtest /home /plugins
77

8+
# Useful during tests to have these packages in a deeper layer cached already.
9+
# RUN apk --no-cache add --virtual vim-build build-base
10+
811
ADD scripts/argecho.sh /vim-build/bin/argecho
912
ADD scripts/install_vim.sh /sbin/install_vim
1013
ADD scripts/run_vim.sh /sbin/run_vim

Makefile

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: build push test
22

3-
TAG:=2
3+
TAG:=3
44

55
build:
66
docker build -t testbed/vim:$(TAG) .
@@ -10,9 +10,6 @@ push:
1010

1111
# test: build the base image and example image on top, running tests therein.
1212
DOCKER_BASE_IMAGE:=vim-testbed-base
13-
DOCKER_EXAMPLE_IMAGE:=vim-testbed-example
1413
test:
15-
docker build -t "$(DOCKER_BASE_IMAGE)" . \
16-
&& cd example \
17-
&& docker build -f Dockerfile.tests -t "$(DOCKER_EXAMPLE_IMAGE)" . \
18-
&& make test IMAGE=$(DOCKER_EXAMPLE_IMAGE)
14+
docker build -t "$(DOCKER_BASE_IMAGE)" .
15+
make -C example test

README.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ tests with Travis-CI where you have to either:
1717
With this base image, you can build the versions you need and reuse them in
1818
future tests.
1919

20-
2120
## Usage
2221

2322
The README is a work in progress. Take a look in the `example` directory and
@@ -31,29 +30,32 @@ your [Docker Hub](https://hub.docker.com/) repository.
3130
```Dockerfile
3231
FROM testbed/vim:latest
3332

34-
RUN install_vim -tag v7.3 -name vim73 -build \
35-
-tag v7.4.052 -name vim74 -build \
36-
-tag master -build
33+
RUN install_vim -tag v7.3.429 -name vim73 -py -build \
34+
-tag v7.4.052 -name vim74-trusty -build \
35+
-tag master -py2 -py3 -ruby -lua -build \
36+
-tag neovim:v0.1.7 -py2 -py3 -ruby -build \
37+
-tag neovim:master -py2 -py3 -ruby -build
38+
3739
```
3840

3941
The `install_vim` script builds one or more versions of Vim that you would like
4042
to use for testing. Each version should be terminated with a `-build` flag to
4143
tell the script to start a build.
4244

43-
The following flags can be used for each build:
45+
The following flags are available for each build:
4446

4547
Flag | Description
4648
---- | -----------
47-
`-tag` | The Vim release. It must match the tags on Vim's [releases page](https://github.com/vim/vim/releases).
48-
`-name` | The name to use for the binary's symlink. If omitted, the name will default to `vim-$TAG`.
49-
`-py` | Build with Python 2. Can't be used with `-py3`.
50-
`-py3` | Build with Python 3. Can't be used with `-py`.
49+
`-tag` | The Vim/Neovim release. It should be a valid tag/commit hash, with an optional GitHub repo prefix. E.g. `master`, `neovim:master`, `neovim:v0.1.7`, or `username/neovim:branch`.
50+
`-flavor` | The Vim flavor. Either `vim` (default) or `neovim`. If empty, it will be detected from `-tag`.
51+
`-name` | The name to use for the binary's symlink. It defaults to `$FLAVOR-$TAG`, e.g. `vim-master` or `neovim-v0.1.7`.
52+
`-py` | Build with Python 2.
53+
`-py3` | Build with Python 3.
5154
`-ruby` | Build with Ruby.
52-
`-lua` | Build with Lua.
53-
54-
All other arguments (up until `-build`) will be passed through to
55-
`./configure`, e.g. `--disable-FEATURE` etc.
55+
`-lua` | Build with Lua (not supported / ignored with Neovim).
5656

57+
With `-flavor vim` (the default), all other arguments (up until `-build`) get
58+
passed through to `./configure`, e.g. `--disable-FEATURE` etc.
5759

5860
### Build
5961

@@ -76,7 +78,6 @@ In this case `vim74`. Arguments after the name is passed to Vim.
7678
The entry point script prefixes your arguments with `-u /home/vimrc -i NONE`.
7779
They can be overridden with your arguments.
7880

79-
8081
## Setup
8182

8283
The base image is created with automated testing in mind. It is not meant to
@@ -99,7 +100,6 @@ source /rtp.vim
99100
It will add `/home/vim` and `/home/vim/after` to the runtime path, and search
100101
for plugins in `/home/plugins`.
101102

102-
103103
### Volumes
104104

105105
Two volumes are provided:

example/Dockerfile

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM testbed/vim
22

3-
RUN install_vim -name vim-precise -tag v7.3.429 -build \
4-
-name vim-trusty -tag v7.4.052 -build \
5-
-name vim-vivid -tag v7.4.488 -build \
6-
-name vim-wily -tag v7.4.712 -build \
7-
-name vim-xenial -tag v7.4.963 -build
3+
RUN install_vim -tag v7.3.429 -name vim73 -py -build \
4+
-tag v7.4.052 -name vim74-trusty -build \
5+
-tag master -py2 -py3 -ruby -lua -build \
6+
-tag neovim:v0.1.7 -py2 -py3 -ruby -build \
7+
-tag neovim:master -py2 -py3 -ruby -build

example/Dockerfile.tests

-8
This file was deleted.

example/Makefile

+74-24
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,81 @@
1-
IMAGE ?= tweekmonster/ubuntu-vims
2-
PLUGINS = test/plugins
3-
DOCKER = docker run -a stderr --rm -v $(PWD):/testplugin -v $(PWD)/test:/home "$(IMAGE)"
4-
5-
$(PLUGINS)/vader.vim:
6-
mkdir -p $(PLUGINS)
7-
cd $(PLUGINS) && git clone https://github.com/junegunn/vader.vim.git
8-
9-
test-setup: $(PLUGINS)/vader.vim
10-
docker images -q $(IMAGE) || docker pull $(IMAGE)
1+
SHELL := $(shell which bash)
2+
IMAGE := vim-testbed-example
3+
PLUGINS := test/plugins
4+
# A writable home directory, required for Neovim.
5+
WRITABLE_HOME:=$(shell tmpdir=$$(mktemp -d --dry-run); \
6+
mkdir -m 777 $${tmpdir}; \
7+
cd $(CURDIR)/test; \
8+
cp -a vimrc *.vader $${tmpdir}/; \
9+
echo $${tmpdir})
10+
DOCKER = docker run -a stderr --rm \
11+
-v $(CURDIR):/testplugin \
12+
-v $(WRITABLE_HOME):/home \
13+
-v $(CURDIR)/$(PLUGINS):/home/plugins "$(IMAGE)"
1114

1215
test: test-setup
13-
vims=$$(docker run --rm $(IMAGE) ls /vim-build/bin | grep -E '^n?vim'); \
16+
docker build -f Dockerfile.tests -t "$(IMAGE)" .
17+
set -ex; \
18+
vims="$$(docker run --rm $(IMAGE) ls /vim-build/bin | grep vim)"; \
1419
if [ -z "$$vims" ]; then echo "No Vims found!"; exit 1; fi; \
20+
count_vims=0; \
1521
for vim in $$vims; do \
22+
(( ++count_vims )); \
1623
$(DOCKER) $$vim '+Vader! test/*'; \
17-
done
18-
out=$$(docker run --rm "$(IMAGE)" /vim-build/bin/argecho "arg1" "arg 2"); \
19-
for line in "PWD=/" "Running as: root" "Arguments:" "arg1" "arg 2"; do \
20-
if ! echo "$$out" | grep -qFx -e "$$line"; then \
21-
echo "Line not found: $$line"; echo "$$out"; exit 1; \
22-
fi \
23-
done
24-
out=$$(docker run --rm "$(IMAGE)" argecho "arg1" "arg 2"); \
25-
for line in "Running as: vimtest" "PWD=/testplugin" "Arguments:" "-u" "/home/vimrc" "-i" "NONE" "arg1" "arg 2"; do \
26-
if ! echo "$$out" | grep -qFx -e "$$line"; then \
27-
echo "Line not found: $$line"; echo "$$out"; exit 1; \
28-
fi \
29-
done
24+
done; \
25+
expected_vims=$$(egrep -c -- '^[^#]+\s-tag' Dockerfile.tests); \
26+
if [ "$$count_vims" != "$$expected_vims" ]; then \
27+
echo "Expected $$expected_vims Vims, but found $$count_vims: $$vims" >&2; \
28+
exit 1; \
29+
fi; \
30+
for vim in "neovim-master --headless" vim-master; do \
31+
$(DOCKER) $${vim} -u NONE \
32+
"+py import sys; open('/home/py2', 'w').write(str(sys.version_info[0]))" \
33+
"+py3 import sys; open('/home/py3', 'w').write(str(sys.version_info[0]))" \
34+
'+q'; \
35+
if [ "$$(<$(WRITABLE_HOME)/py2)" != "2" ]; then \
36+
echo "Failed to get Python version from $${vim} (2)." >&2; exit 1; \
37+
fi; \
38+
if [ "$$(<$(WRITABLE_HOME)/py3)" != "3" ]; then \
39+
echo "Failed to get Python version from $${vim} (3)." >&2; exit 1; \
40+
fi; \
41+
$(RM) $(WRITABLE_HOME)/py*; \
42+
done; \
43+
for vim in "neovim-master --headless" vim-master; do \
44+
$(DOCKER) $${vim} -u NONE \
45+
"+ruby open('/home/ruby', 'w') { |f| f << 'ruby was here' }" \
46+
'+q'; \
47+
if [ "$$(<$(WRITABLE_HOME)/ruby)" != "ruby was here" ]; then \
48+
echo "Failed to get output from Ruby for $${vim}." >&2; exit 1; \
49+
fi; \
50+
$(RM) $(WRITABLE_HOME)/ruby; \
51+
done; \
52+
$(DOCKER) vim-master -u NONE \
53+
"+lua io.open('/home/lua', 'w'):write('lua was here')" \
54+
'+q'; \
55+
if [ "$$(<$(WRITABLE_HOME)/lua)" != "lua was here" ]; then \
56+
echo "Failed to get output from Lua for $${vim}." >&2; exit 1; \
57+
fi; \
58+
neovim_tag_version=$$(docker run --rm "$(IMAGE)" neovim-v0.1.7 -u NONE --version | grep '^NVIM'); \
59+
if [ "$$neovim_tag_version" != 'NVIM 0.1.7' ]; then \
60+
echo "Unexpected version for Neovim tag: $$neovim_tag_version" >&2; \
61+
exit 1; \
62+
fi; \
63+
neovim_master_version=$$(docker run --rm "$(IMAGE)" neovim-master -u NONE --version | grep '^NVIM'); \
64+
if ! echo "$$neovim_master_version" | grep -Eq '^NVIM v[0-9.]+-dev-[0-9a-f]+$$'; then \
65+
echo "Unexpected version for Neovim master: $$neovim_master_version" >&2; \
66+
exit 1; \
67+
fi;
68+
69+
test-setup: Dockerfile.tests $(PLUGINS)/vader.vim
70+
docker images -q $(IMAGE) || docker pull $(IMAGE)
71+
72+
Dockerfile.tests: Dockerfile
73+
( echo '# Autogenerated Dockerfile for tests.'; \
74+
echo '# Edit with care (generated from updates to Dockerfile).'; \
75+
sed 's~testbed/vim~vim-testbed-base~' $< ) > $@
76+
77+
$(PLUGINS)/vader.vim:
78+
mkdir -p $(PLUGINS)
79+
cd $(PLUGINS) && git clone https://github.com/junegunn/vader.vim.git
3080

3181
.PHONY: test-setup test

example/test/vimrc

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
" vint: -ProhibitSetNoCompatible
12
source /rtp.vim
23

34
filetype plugin indent on
@@ -13,5 +14,3 @@ set foldmethod=syntax
1314
set foldlevelstart=10
1415
set foldnestmax=10
1516
set ttimeoutlen=0
16-
17-
let mapleader=","

0 commit comments

Comments
 (0)