1
0
mirror of https://github.com/amix/vimrc synced 2025-06-16 01:25:00 +08:00

Updated plugins

This commit is contained in:
amix
2017-02-11 14:01:38 +01:00
parent a6de243fca
commit fe46dfbbe6
141 changed files with 2790 additions and 1630 deletions

View File

@ -0,0 +1,81 @@
let total_started = reltime()
" add vim-go the only plugin inside the runtimepath
let git_root_path = system("git rev-parse --show-toplevel | tr -d '\\n'")
exe 'set rtp=' . git_root_path
" source the passed test file
source %
" cd into the folder of the test file
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
let dir = getcwd()
execute cd . expand('%:p:h')
" initialize variables
let g:testname = expand('%')
let s:fail = 0
let s:done = 0
let s:logs = []
" get a list of all Test_ functions for the given file
set nomore
redir @q
silent function /^Test_
redir END
let s:tests = split(substitute(@q, 'function \(\k*()\)', '\1', 'g'))
" Iterate over all tests and execute them
for s:test in sort(s:tests)
let started = reltime()
call add(s:logs, printf("=== RUN %s", s:test[:-3]))
exe 'call ' . s:test
let elapsed_time = reltimestr(reltime(started))
let elapsed_time = substitute(elapsed_time, '^\s*\(.\{-}\)\s*$', '\1', '')
let s:done += 1
if len(v:errors) > 0
let s:fail += 1
call add(s:logs, printf("--- FAIL: %s (%ss)", s:test[:-3], elapsed_time))
call extend(s:logs, map(v:errors, '" ". v:val'))
" reset so we can capture failures of next test
let v:errors = []
else
call add(s:logs, printf("--- PASS: %s (%ss)", s:test[:-3], elapsed_time))
endif
endfor
" pop out into the scripts folder
execute cd . fnameescape(dir)
" create an empty fail to indicate that the test failed
if s:fail > 0
split FAILED
write
endif
let total_elapsed_time = reltimestr(reltime(total_started))
let total_elapsed_time = substitute(total_elapsed_time, '^\s*\(.\{-}\)\s*$', '\1', '')
let message = 'Executed ' . s:done . (s:done > 1 ? ' tests' : ' test') . '. Total test time: '. total_elapsed_time .'s'
call add(s:logs, "")
call add(s:logs, message)
" store all error messages from within vim into test.log
redir > test.log
silent messages
redir END
" also store all internal messages from s:logs: as well
split test.log
call append(line('$'), '')
call append(line('$'), 'From ' . g:testname . ':')
call append(line('$'), s:logs)
write
" bye, bye!
qall!

View File

@ -1,77 +1,29 @@
#!/bin/bash -e
#
# Copyright 2012 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
#
# Tests for import.vim.
#!/bin/bash
set -e
cd $(dirname $0)
cat > base.go <<EOF
package test
# cleanup test.log
if [ -f "test.log" ]; then
rm test.log
fi
import (
"bytes"
"io"
"net"
if [ -f "FAILED" ]; then
rm FAILED
fi
"mycorp/foo"
)
EOF
for test_file in ../autoload/go/*_test.vim
do
vim -u NONE -S runtest.vim $test_file
done
fail=0
if [ -f "test.log" ]; then
cat test.log
fi
# usage: test_one command pattern
# Pattern is a PCRE expression that will match across lines.
test_one() {
echo 2>&1 -n "$1: "
vim -e -s -u /dev/null -U /dev/null --noplugin -c "source import.vim" \
-c "$1" -c 'wq! test.go' base.go
# ensure blank lines are treated correctly
if ! gofmt test.go | cmp test.go -; then
echo 2>&1 "gofmt conflict"
gofmt test.go | diff -u test.go - | sed "s/^/ /" 2>&1
fail=1
return
fi
if ! [[ $(cat test.go) =~ $2 ]]; then
echo 2>&1 "$2 did not match"
cat test.go | sed "s/^/ /" 2>&1
fail=1
return
fi
echo 2>&1 "ok"
}
# Tests for Import
test_one "Import baz" '"baz".*"bytes"'
test_one "Import io/ioutil" '"io".*"io/ioutil".*"net"'
test_one "Import myc" '"io".*"myc".*"net"' # prefix of a site prefix
test_one "Import nat" '"io".*"nat".*"net"'
test_one "Import net/http" '"net".*"net/http".*"mycorp/foo"'
test_one "Import zoo" '"net".*"zoo".*"mycorp/foo"'
test_one "Import mycorp/bar" '"net".*"mycorp/bar".*"mycorp/foo"'
test_one "Import mycorp/goo" '"net".*"mycorp/foo".*"mycorp/goo"'
# Tests for Drop
cat > base.go <<EOF
package test
import (
"foo"
"something"
"zoo"
)
EOF
test_one "Drop something" '\([^"]*"foo"[^"]*"zoo"[^"]*\)'
rm -f base.go test.go
if [ $fail -gt 0 ]; then
# if Failed exists, test failed
if [ -f "FAILED" ]; then
echo 2>&1 "FAIL"
exit 1
fi