Skip to content

Commit

Permalink
WIP: improve testplugin setup
Browse files Browse the repository at this point in the history
Fixes Vimjas#8
  • Loading branch information
blueyed committed May 13, 2017
1 parent f90a0ba commit bda9cce
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 32 deletions.
16 changes: 9 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
FROM alpine:3.5

RUN adduser -h /home -s /bin/sh -D -u 8465 vimtest
RUN adduser -h /home/testbed -s /bin/sh -D -u 8465 vimtest

RUN mkdir -p /vim /vim-build/bin /plugins
RUN chown vimtest:vimtest /home /plugins
RUN mkdir -p /vim /vim-build/bin

# Useful during tests to have these packages in a deeper layer cached already.
# RUN apk --no-cache add --virtual vim-build build-base
Expand All @@ -12,14 +11,17 @@ ADD scripts/argecho.sh /vim-build/bin/argecho
ADD scripts/install_vim.sh /sbin/install_vim
ADD scripts/run_vim.sh /sbin/run_vim

RUN chmod +x /vim-build/bin/argecho /sbin/install_vim /sbin/run_vim
RUN mkdir /home/testbed/.vim /home/testbed/.config
ADD scripts/init.vim /home/testbed/.vim/
RUN ln -s ../.vim /home/testbed/.config/nvim
RUN ln -s .vim/init.vim /home/testbed/.vimrc

ADD scripts/rtp.vim /rtp.vim
RUN chmod +x /vim-build/bin/argecho /sbin/install_vim /sbin/run_vim

# The user directory for setup
VOLUME /home
VOLUME /home/testbed

# Your plugin
VOLUME /testplugin
VOLUME /testbed

ENTRYPOINT ["/sbin/run_vim"]
10 changes: 6 additions & 4 deletions example/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ WRITABLE_HOME:=$(shell tmpdir=$$(mktemp -d --dry-run); \
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)"
TODO: remove/unneeded by now?!
# -v $(WRITABLE_HOME):/home/testbed \

DOCKER = docker run -ti --rm \
-v $(CURDIR):/testbed \
-v $(CURDIR)/$(PLUGINS):/home/testbed/.vim/plugins "$(IMAGE)"

test: test-setup
docker build -f Dockerfile.tests -t "$(IMAGE)" .
Expand Down
16 changes: 0 additions & 16 deletions example/test/vimrc

This file was deleted.

2 changes: 2 additions & 0 deletions scripts/init.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
set runtimepath+=/testbed
source /testbed/testbed.vim
3 changes: 0 additions & 3 deletions scripts/rtp.vim

This file was deleted.

4 changes: 2 additions & 2 deletions scripts/run_vim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if ! [ -x "/vim-build/bin/$BIN" ]; then
fi

# Set default vimrc to a visible file
ARGS="-u /home/vimrc -i NONE"
ARGS="-i NONE"

# So we can pass the arguments to Vim as it was passed to this script
while [ $# -gt 0 ]; do
Expand All @@ -21,4 +21,4 @@ done

# Run as the vimtest user. This is not really for security. It is for running
# Vim as a user that's unable to write to your volume.
exec su -l vimtest -c "cd /testplugin && /vim-build/bin/$BIN $ARGS"
exec su -l vimtest -c "cd /testbed && env VIM_TESTBED=1 /vim-build/bin/$BIN $ARGS"

0 comments on commit bda9cce

Please sign in to comment.