From 40a7366b8fb9b60b6104b11652e3524e3a43ff71 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 | 7 +++---- example/{test/vimrc => testbed.vim} | 4 +++- scripts/init.vim | 2 ++ scripts/rtp.vim | 3 --- scripts/run_vim.sh | 7 +++---- 6 files changed, 18 insertions(+), 17 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..4575f44 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/vimtest/.vim /home/vimtest/.config +ADD scripts/init.vim /home/vimtest/.vim/ +RUN ln -s ../.vim /home/vimtest/.config/nvim +RUN ln -s .vim/init.vim /home/vimtest/.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 dfb6b52..a536496 100644 --- a/example/Makefile +++ b/example/Makefile @@ -7,10 +7,9 @@ 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/vimtest \ - -v $(CURDIR)/$(PLUGINS):/home/vimtest/plugins "$(IMAGE)" +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 b831ae1..0000000 --- a/scripts/rtp.vim +++ /dev/null @@ -1,3 +0,0 @@ -set rtp=/home/vimtest/vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,/home/vimtest/vim/after -execute 'set rtp+='.join(filter(split(expand('/home/vimtest/plugins/*')), 'isdirectory(v:val)'), ',') -set rtp+=/testplugin diff --git a/scripts/run_vim.sh b/scripts/run_vim.sh index aadcf5c..be33a9c 100644 --- a/scripts/run_vim.sh +++ b/scripts/run_vim.sh @@ -15,7 +15,7 @@ if ! [ -x "/vim-build/bin/$BIN" ]; then fi # Set default vimrc to a visible file -ARGS="-u /home/vimtest/vimrc -i NONE" +ARGS="-i NONE" # Run as the vimtest user (when no USER is specified in the Dockerfile, i.e. # when running as root). @@ -27,10 +27,9 @@ if [ "$(id -u)" = 0 ]; then ARGS="$ARGS \"$1\"" shift done - exec su -l vimtest -c "cd /testplugin && /vim-build/bin/$BIN $ARGS" + exec su -l vimtest -c "cd /testbed && /vim-build/bin/$BIN $ARGS" fi -cd /testplugin || exit - +cd /testbed || exit # shellcheck disable=SC2086 exec "/vim-build/bin/$BIN" "$@"