Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ RUN adduser -h /home -s /bin/sh -D -u 8465 vimtest
RUN mkdir -p /vim /vim-build/bin /plugins
RUN chown vimtest:vimtest /home /plugins

# Useful during tests to have these packages in a deeper layer cached already.
# RUN apk --no-cache add --virtual vim-build build-base

ADD scripts/argecho.sh /vim-build/bin/argecho
ADD scripts/install_vim.sh /sbin/install_vim
ADD scripts/run_vim.sh /sbin/run_vim
Expand Down
9 changes: 3 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: build push test

TAG:=2
TAG:=3

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

# test: build the base image and example image on top, running tests therein.
DOCKER_BASE_IMAGE:=vim-testbed-base
DOCKER_EXAMPLE_IMAGE:=vim-testbed-example
test:
docker build -t "$(DOCKER_BASE_IMAGE)" . \
&& cd example \
&& docker build -f Dockerfile.tests -t "$(DOCKER_EXAMPLE_IMAGE)" . \
&& make test IMAGE=$(DOCKER_EXAMPLE_IMAGE)
docker build -t "$(DOCKER_BASE_IMAGE)" .
make -C example test
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ tests with Travis-CI where you have to either:
With this base image, you can build the versions you need and reuse them in
future tests.


## Usage

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

RUN install_vim -tag v7.3 -name vim73 -build \
-tag v7.4.052 -name vim74 -build \
-tag master -build
RUN install_vim -tag v7.3.429 -name vim73 -py -build \
-tag v7.4.052 -name vim74-trusty -build \
-tag master -py2 -py3 -ruby -lua -build \
-tag neovim:v0.1.7 -py2 -py3 -ruby -build \
-tag neovim:master -py2 -py3 -ruby -build

```

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

The following flags can be used for each build:
The following flags are available for each build:

Flag | Description
---- | -----------
`-tag` | The Vim release. It must match the tags on Vim's [releases page](https://github.com/vim/vim/releases).
`-name` | The name to use for the binary's symlink. If omitted, the name will default to `vim-$TAG`.
`-py` | Build with Python 2. Can't be used with `-py3`.
`-py3` | Build with Python 3. Can't be used with `-py`.
`-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`.
`-flavor` | The Vim flavor. Either `vim` (default) or `neovim`. If empty, it will be detected from `-tag`.
`-name` | The name to use for the binary's symlink. It defaults to `$FLAVOR-$TAG`, e.g. `vim-master` or `neovim-v0.1.7`.
`-py` | Build with Python 2.
`-py3` | Build with Python 3.
`-ruby` | Build with Ruby.
`-lua` | Build with Lua.

All other arguments (up until `-build`) will be passed through to
`./configure`, e.g. `--disable-FEATURE` etc.
`-lua` | Build with Lua (not supported / ignored with Neovim).

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

### Build

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


## Setup

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


### Volumes

Two volumes are provided:
Expand Down
10 changes: 5 additions & 5 deletions example/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM testbed/vim

RUN install_vim -name vim-precise -tag v7.3.429 -build \
-name vim-trusty -tag v7.4.052 -build \
-name vim-vivid -tag v7.4.488 -build \
-name vim-wily -tag v7.4.712 -build \
-name vim-xenial -tag v7.4.963 -build
RUN install_vim -tag v7.3.429 -name vim73 -py -build \
-tag v7.4.052 -name vim74-trusty -build \
-tag master -py2 -py3 -ruby -lua -build \
-tag neovim:v0.1.7 -py2 -py3 -ruby -build \
-tag neovim:master -py2 -py3 -ruby -build
8 changes: 0 additions & 8 deletions example/Dockerfile.tests

This file was deleted.

98 changes: 74 additions & 24 deletions example/Makefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,81 @@
IMAGE ?= tweekmonster/ubuntu-vims
PLUGINS = test/plugins
DOCKER = docker run -a stderr --rm -v $(PWD):/testplugin -v $(PWD)/test:/home "$(IMAGE)"

$(PLUGINS)/vader.vim:
mkdir -p $(PLUGINS)
cd $(PLUGINS) && git clone https://github.com/junegunn/vader.vim.git

test-setup: $(PLUGINS)/vader.vim
docker images -q $(IMAGE) || docker pull $(IMAGE)
SHELL := $(shell which bash)
IMAGE := vim-testbed-example
PLUGINS := test/plugins
# A writable home directory, required for Neovim.
WRITABLE_HOME:=$(shell tmpdir=$$(mktemp -d --dry-run); \
mkdir -m 777 $${tmpdir}; \
cd $(CURDIR)/test; \
cp -a vimrc *.vader $${tmpdir}/; \
echo $${tmpdir})
DOCKER = docker run -a stderr --rm \
-v $(CURDIR):/testplugin \
-v $(WRITABLE_HOME):/home \
-v $(CURDIR)/$(PLUGINS):/home/plugins "$(IMAGE)"

test: test-setup
vims=$$(docker run --rm $(IMAGE) ls /vim-build/bin | grep -E '^n?vim'); \
docker build -f Dockerfile.tests -t "$(IMAGE)" .
set -ex; \
vims="$$(docker run --rm $(IMAGE) ls /vim-build/bin | grep vim)"; \
if [ -z "$$vims" ]; then echo "No Vims found!"; exit 1; fi; \
count_vims=0; \
for vim in $$vims; do \
(( ++count_vims )); \
$(DOCKER) $$vim '+Vader! test/*'; \
done
out=$$(docker run --rm "$(IMAGE)" /vim-build/bin/argecho "arg1" "arg 2"); \
for line in "PWD=/" "Running as: root" "Arguments:" "arg1" "arg 2"; do \
if ! echo "$$out" | grep -qFx -e "$$line"; then \
echo "Line not found: $$line"; echo "$$out"; exit 1; \
fi \
done
out=$$(docker run --rm "$(IMAGE)" argecho "arg1" "arg 2"); \
for line in "Running as: vimtest" "PWD=/testplugin" "Arguments:" "-u" "/home/vimrc" "-i" "NONE" "arg1" "arg 2"; do \
if ! echo "$$out" | grep -qFx -e "$$line"; then \
echo "Line not found: $$line"; echo "$$out"; exit 1; \
fi \
done
done; \
expected_vims=$$(egrep -c -- '^[^#]+\s-tag' Dockerfile.tests); \
if [ "$$count_vims" != "$$expected_vims" ]; then \
echo "Expected $$expected_vims Vims, but found $$count_vims: $$vims" >&2; \
exit 1; \
fi; \
for vim in "neovim-master --headless" vim-master; do \
$(DOCKER) $${vim} -u NONE \
"+py import sys; open('/home/py2', 'w').write(str(sys.version_info[0]))" \
"+py3 import sys; open('/home/py3', 'w').write(str(sys.version_info[0]))" \
'+q'; \
if [ "$$(<$(WRITABLE_HOME)/py2)" != "2" ]; then \
echo "Failed to get Python version from $${vim} (2)." >&2; exit 1; \
fi; \
if [ "$$(<$(WRITABLE_HOME)/py3)" != "3" ]; then \
echo "Failed to get Python version from $${vim} (3)." >&2; exit 1; \
fi; \
$(RM) $(WRITABLE_HOME)/py*; \
done; \
for vim in "neovim-master --headless" vim-master; do \
$(DOCKER) $${vim} -u NONE \
"+ruby open('/home/ruby', 'w') { |f| f << 'ruby was here' }" \
'+q'; \
if [ "$$(<$(WRITABLE_HOME)/ruby)" != "ruby was here" ]; then \
echo "Failed to get output from Ruby for $${vim}." >&2; exit 1; \
fi; \
$(RM) $(WRITABLE_HOME)/ruby; \
done; \
$(DOCKER) vim-master -u NONE \
"+lua io.open('/home/lua', 'w'):write('lua was here')" \
'+q'; \
if [ "$$(<$(WRITABLE_HOME)/lua)" != "lua was here" ]; then \
echo "Failed to get output from Lua for $${vim}." >&2; exit 1; \
fi; \
neovim_tag_version=$$(docker run --rm "$(IMAGE)" neovim-v0.1.7 -u NONE --version | grep '^NVIM'); \
if [ "$$neovim_tag_version" != 'NVIM 0.1.7' ]; then \
echo "Unexpected version for Neovim tag: $$neovim_tag_version" >&2; \
exit 1; \
fi; \
neovim_master_version=$$(docker run --rm "$(IMAGE)" neovim-master -u NONE --version | grep '^NVIM'); \
if ! echo "$$neovim_master_version" | grep -Eq '^NVIM v[0-9.]+-dev-[0-9a-f]+$$'; then \
echo "Unexpected version for Neovim master: $$neovim_master_version" >&2; \
exit 1; \
fi;

test-setup: Dockerfile.tests $(PLUGINS)/vader.vim
docker images -q $(IMAGE) || docker pull $(IMAGE)

Dockerfile.tests: Dockerfile
( echo '# Autogenerated Dockerfile for tests.'; \
echo '# Edit with care (generated from updates to Dockerfile).'; \
sed 's~testbed/vim~vim-testbed-base~' $< ) > $@

$(PLUGINS)/vader.vim:
mkdir -p $(PLUGINS)
cd $(PLUGINS) && git clone https://github.com/junegunn/vader.vim.git

.PHONY: test-setup test
3 changes: 1 addition & 2 deletions example/test/vimrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
" vint: -ProhibitSetNoCompatible
source /rtp.vim

filetype plugin indent on
Expand All @@ -13,5 +14,3 @@ set foldmethod=syntax
set foldlevelstart=10
set foldnestmax=10
set ttimeoutlen=0

let mapleader=","
Loading