-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better testing - Support multiple Vim versions (currently 7.4, 8.0, and Neovim). - Make sure that we always run Vim from a temporary installation in `/tmp/vim-go-test` without loading `~/.vim`. This makes it a lot easier to run on people's computers. - Also add a handy `./script/run-vim` script to run the installed Vim from the temp directory. Useful for testing, debugging, etc. without a (potentially large) ~/.vim/ dir. - Previously the tests weren't actually being run correctly; see: https://travis-ci.org/fatih/vim-go/builds/279277579 - Format the output of the tests a wee bit nicer, roughly similar to the `go test` output. - Expand docs on testing a bit. I also attempted to integrate code coverage support with https://github.com/Vimjas/covimerage (which was the reason I started working on this), but couldn't really get that to work. Need to look in to that later.
- Loading branch information
Showing
14 changed files
with
340 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.git/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
Thanks for improving vim-go! Before you dive in please read the following: | ||
|
||
1. Please read our | ||
[Documentation](https://github.com/fatih/vim-go/blob/master/doc/vim-go.txt), it might | ||
have answers for your problem | ||
2. If you add a new feature please don't forget to update the documentation: | ||
[Documentation](https://github.com/fatih/vim-go/blob/master/doc/vim-go.txt), | ||
it might have a solution to your problem. | ||
2. If you add a new feature then please don't forget to update the documentation: | ||
[doc/vim-go.txt](https://github.com/fatih/vim-go/blob/master/doc/vim-go.txt). | ||
3. If it's a breaking change or exceed +100 lines please open an issue first | ||
and describe the changes you want to make. | ||
3. If it's a breaking change or exceeds 100 lines of code then please open an | ||
issue first and describe the changes you want to make. | ||
4. See `:help go-development` for instructions on how to run and write tests. If | ||
you add a new feature be sure you also include a test if feasible. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,2 @@ | ||
doc/tags | ||
.DS_Store | ||
|
||
# Test specific files | ||
FAILED | ||
test.log | ||
scripts/vim-vimhelplint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,11 @@ | ||
language: go | ||
|
||
env: | ||
global: | ||
- DEPS=$HOME/deps | ||
- PATH=$DEPS/bin:$PATH | ||
- PATCH="v8.0.0134" | ||
|
||
install: | | ||
git config --global user.email "you@example.com" | ||
git config --global user.name "Your Name" | ||
# check out if we can pre-compiled Vim releases somehow, | ||
git clone --branch $PATCH --depth 1 https://github.com/vim/vim | ||
cd vim | ||
./configure --prefix=$DEPS --with-features=huge --disable-gui | ||
make | ||
make install | ||
cd - | ||
script: ./scripts/test.sh | ||
matrix: | ||
include: | ||
- env: SCRIPT=test VIM_VERSION=vim-7.4 | ||
- env: SCRIPT=test VIM_VERSION=vim-8.0 | ||
- env: SCRIPT=test VIM_VERSION=nvim | ||
- env: SCRIPT=lint VIM_VERSION=vim-8.0 | ||
install: | ||
- ./scripts/install-vim $VIM_VERSION | ||
script: | ||
- ./scripts/$SCRIPT $VIM_VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM golang:1.9.1 | ||
|
||
RUN apt-get update -y && \ | ||
apt-get install -y build-essential curl git libncurses5-dev && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
RUN useradd -ms /bin/bash -d /vim-go vim-go | ||
USER vim-go | ||
WORKDIR /vim-go | ||
COPY . /vim-go/ | ||
|
||
ENTRYPOINT ["make"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,24 @@ | ||
all: test | ||
all: install test lint | ||
|
||
install: | ||
@echo "==> Installing Vims" | ||
@./scripts/install-vim vim-7.4 | ||
@./scripts/install-vim vim-8.0 | ||
@./scripts/install-vim nvim | ||
|
||
test: | ||
@echo "==> Running tests" | ||
@./scripts/test.sh | ||
@./scripts/test vim-7.4 | ||
@./scripts/test vim-8.0 | ||
@./scripts/test nvim | ||
|
||
lint: | ||
@echo "==> Running linting tools" | ||
@./scripts/lint vim-8.0 | ||
|
||
clean: | ||
@echo "==> Cleaning /tmp/vim-go-test" | ||
@rm -rf /tmp/vim-go-test | ||
|
||
|
||
.PHONY: all test | ||
.PHONY: all test install clean lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#!/bin/sh | ||
# | ||
# Install and setup a Vim or Neovim for running tests. | ||
# This should work on both Travis and people's desktop computers, and be 100% | ||
# independent from any system installed Vim. | ||
# | ||
# It will echo the full path to a Vim binary, e.g.: | ||
# /some/path/src/vim | ||
|
||
set -euC | ||
|
||
vimgodir=$(cd -P "$(dirname "$0")/.." > /dev/null && pwd) | ||
cd "$vimgodir" | ||
|
||
vim=${1:-} | ||
|
||
case "$vim" in | ||
"vim-7.4") | ||
# This is what the most recent Ubuntu LTS (16.04) ships with. | ||
tag="v7.4.1689" | ||
giturl="https://github.com/vim/vim" | ||
;; | ||
|
||
"vim-8.0") | ||
# This follows the version in Arch Linux. Vim's master branch isn't always | ||
# stable, and we don't want to have the build fail because Vim introduced a | ||
# bug. | ||
tag="v8.0.1176" | ||
giturl="https://github.com/vim/vim" | ||
;; | ||
|
||
"nvim") | ||
# Use latest stable version. | ||
tag="v0.2.0" | ||
giturl="https://github.com/neovim/neovim" | ||
;; | ||
|
||
*) | ||
echo "unknown version: '${1:-}'" | ||
echo "First argument must be 'vim-7.4', 'vim-8.0', or 'nvim'." | ||
exit 1 | ||
;; | ||
esac | ||
|
||
srcdir="/tmp/vim-go-test/$1-src" | ||
installdir="/tmp/vim-go-test/$1-install" | ||
|
||
# Use cached installdir. | ||
if [ -d "$installdir" ]; then | ||
echo "$installdir exists; skipping build." | ||
|
||
# The ./scripts/test script relies on this. | ||
echo "installed to: $installdir" | ||
exit 0 | ||
fi | ||
|
||
mkdir -p "$srcdir" | ||
cd "$srcdir" | ||
|
||
# Neovim build requires more deps than Vim and is annoying, so we use the | ||
# binary. | ||
# 0.2.0 doesn't have a binary build for Linux, so we use 0.2.1-dev for now. | ||
if [ "$1" = "nvim" ]; then | ||
|
||
# TODO: Use macOS binaries on macOS | ||
curl -Ls https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.tar.gz | | ||
tar xzf - -C /tmp/vim-go-test/ | ||
mv /tmp/vim-go-test/nvim-linux64 /tmp/vim-go-test/nvim-install | ||
mkdir -p "$installdir/share/nvim/runtime/pack/vim-go/start" | ||
ln -s "$vimgodir" "$installdir/share/nvim/runtime/pack/vim-go/start/vim-go" | ||
|
||
# Consistent paths makes calling things easier. | ||
mv "$installdir/bin/nvim" "$installdir/bin/vim" | ||
mkdir -p "$installdir/share/vim/vimgo/pack" | ||
ln -s "$installdir/share/nvim/runtime/pack/vim-go" "$installdir/share/vim/vimgo/pack/vim-go" | ||
|
||
# Build Vim from source. | ||
else | ||
if [ -d "$srcdir/.git" ]; then | ||
echo "Skipping clone as $srcdir/.git exists" | ||
else | ||
echo "Cloning $tag from $giturl" | ||
git clone --branch "$tag" --depth 1 "$giturl" "$srcdir" | ||
fi | ||
|
||
./configure --prefix="$installdir" --with-features=huge --disable-gui | ||
make install | ||
mkdir -p "$installdir/share/vim/vimgo/pack/vim-go/start" | ||
ln -s "$vimgodir" "$installdir/share/vim/vimgo/pack/vim-go/start/vim-go" | ||
fi | ||
|
||
# Make sure all Go tools and other dependencies are installed. | ||
export GOPATH=$installdir | ||
export PATH=${GOPATH}/bin:$PATH | ||
"$vimgodir/scripts/run-vim" $vim +':silent :GoUpdateBinaries' +':qa' | ||
|
||
[ -d "$installdir/share/vim/vimgo/pack/vim-go/start/vim-vimhelplint" ] || \ | ||
git clone --depth 1 --quiet https://github.com/machakann/vim-vimhelplint \ | ||
"$installdir/share/vim/vimgo/pack/vim-go/start/vim-vimhelplint" | ||
|
||
# Don't really need source after successful install. | ||
rm -rf "$srcdir" | ||
|
||
echo "installed to: $installdir" | ||
|
||
# vim:ts=2:sts=2:sw=2:et |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/sh | ||
# | ||
# Run all linting tools. | ||
# | ||
|
||
set -euC | ||
vimgodir=$(cd -P "$(dirname "$0")/.." > /dev/null && pwd) | ||
cd "$vimgodir" | ||
|
||
### Setup Vim and other dependencies. | ||
##################################### | ||
if [ -z "${1:-}" ]; then | ||
echo "unknown version: '${1:-}'" | ||
echo "First argument must be 'vim-7.4', 'vim-8.0', or 'nvim'." | ||
exit 1 | ||
fi | ||
|
||
vim=$1 | ||
vimdir="/tmp/vim-go-test/$vim-install" | ||
export GOPATH=$vimdir | ||
export PATH=${GOPATH}/bin:$PATH | ||
|
||
if [ ! -f "$vimdir/bin/vim" ]; then | ||
echo "$vimdir/bin/vim doesn't exist; did you install it with the install-vim script?" | ||
exit 1 | ||
fi | ||
|
||
### Run vimhelplint. | ||
#################### | ||
printf "Running vimhelplint ... " | ||
|
||
# set modeline explicitly so that the modeline will be respected when run as root. | ||
lint=$($vimdir/bin/vim -esNR \ | ||
--cmd "set rtp+=$vimdir/share/vim/vimgo/pack/vim-go/start/vim-vimhelplint/" \ | ||
--cmd 'set modeline' \ | ||
+'filetype plugin on' \ | ||
+"e $vimgodir/doc/vim-go.txt" \ | ||
+'verbose VimhelpLintEcho' \ | ||
+q \ | ||
2>&1) | ||
if [ "$lint" ]; then | ||
echo "FAILED" | ||
echo "$lint" | ||
exit 6 | ||
else | ||
echo "PASSED" | ||
exit 0 | ||
fi |
Oops, something went wrong.