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 Nov 4, 2017
1 parent ff5bf66 commit 40a7366
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
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/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"]
7 changes: 3 additions & 4 deletions example/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)" .
Expand Down
4 changes: 3 additions & 1 deletion example/test/vimrc → example/testbed.vim
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
" vint: -ProhibitSetNoCompatible
source /rtp.vim

let s:this_dir = expand('<sfile>:h')
exe 'set runtimepath+='.s:this_dir.'/test/plugins/vader.vim'

filetype plugin indent on
syntax on
Expand Down
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.

7 changes: 3 additions & 4 deletions scripts/run_vim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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" "$@"

0 comments on commit 40a7366

Please sign in to comment.