From a29aeba782f6e8ec07daa84447afc21ddb0da52c Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 13 May 2017 17:57:32 +0200 Subject: [PATCH] WIP: improve testplugin setup Fixes https://github.com/tweekmonster/vim-testbed/issues/8 --- Dockerfile | 12 +++++++----- example/Makefile | 10 ++++++---- example/{test/vimrc => testbed.vim} | 4 +++- scripts/init.vim | 2 ++ scripts/rtp.vim | 3 --- scripts/run_vim.sh | 4 ++-- 6 files changed, 20 insertions(+), 15 deletions(-) rename example/{test/vimrc => testbed.vim} (72%) create mode 100644 scripts/init.vim delete mode 100644 scripts/rtp.vim diff --git a/Dockerfile b/Dockerfile index fc890f1..2742456 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,7 @@ FROM alpine:3.6 RUN adduser -h /home/vimtest -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 @@ -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/vimtest # Your plugin -VOLUME /testplugin +VOLUME /testbed ENTRYPOINT ["/sbin/run_vim"] diff --git a/example/Makefile b/example/Makefile index 525ed94..3ce6a73 100644 --- a/example/Makefile +++ b/example/Makefile @@ -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)" . diff --git a/example/test/vimrc b/example/testbed.vim similarity index 72% rename from example/test/vimrc rename to example/testbed.vim index 0a96881..0c31a51 100644 --- a/example/test/vimrc +++ b/example/testbed.vim @@ -1,5 +1,7 @@ " vint: -ProhibitSetNoCompatible -source /rtp.vim + +let s:this_dir = expand(':h') +exe 'set runtimepath+='.s:this_dir.'/test/plugins/vader.vim' filetype plugin indent on syntax on diff --git a/scripts/init.vim b/scripts/init.vim new file mode 100644 index 0000000..44a5fb1 --- /dev/null +++ b/scripts/init.vim @@ -0,0 +1,2 @@ +set runtimepath+=/testbed +source /testbed/testbed.vim diff --git a/scripts/rtp.vim b/scripts/rtp.vim deleted file mode 100644 index d0b1a6c..0000000 --- a/scripts/rtp.vim +++ /dev/null @@ -1,3 +0,0 @@ -set rtp=/home/vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,/home/vim/after -execute 'set rtp+='.join(filter(split(expand('/home/plugins/*')), 'isdirectory(v:val)'), ',') -set rtp+=/testplugin diff --git a/scripts/run_vim.sh b/scripts/run_vim.sh index e1d664a..00d0c9a 100644 --- a/scripts/run_vim.sh +++ b/scripts/run_vim.sh @@ -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 @@ -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"