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

Updated plugins, also experimenting with a new font

The font is IBM Plex Mono: https://ibm.github.io/type/
This commit is contained in:
amix
2017-11-24 14:54:40 +01:00
parent 7fc202ec88
commit e9aac9794b
255 changed files with 2898 additions and 3752 deletions

View File

@ -1,81 +1,87 @@
let total_started = reltime()
" Make sure some options are set to sane defaults and output all messages in
" English.
" 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
" vint: -ProhibitSetNoCompatible
set nocompatible nomore shellslash encoding=utf-8 shortmess+=WIF
lang mess C
" 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('%')
" Initialize variables.
let s:total_started = reltime()
let s:fail = 0
let s:done = 0
let s:logs = []
let s:gopath = $GOPATH
" get a list of all Test_ functions for the given file
set nomore
" Source the passed test file.
source %
" cd into the folder of the test file.
let s:cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
let s:testfile = expand('%:t')
execute s:cd . expand('%:p:h')
" Export root path to vim-go dir.
let g:vim_go_root = fnamemodify(getcwd(), ':p')
" Get a list of all Test_ functions for the given file.
redir @q
silent function /^Test_
silent function /^Test_
redir END
let s:tests = split(substitute(@q, 'function \(\k*()\)', '\1', 'g'))
" Iterate over all tests and execute them
" Iterate over all tests and execute them.
for s:test in sort(s:tests)
let started = reltime()
" Since we extract the tests from a regexp the "abort" keyword is also in the
" list, which is not a test name :-)
if s:test == 'abort'
continue
endif
call add(s:logs, printf("=== RUN %s", s:test[:-3]))
let s: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', '')
" Restore GOPATH after each test.
let $GOPATH = s:gopath
let s:elapsed_time = substitute(reltimestr(reltime(s:started)), '^\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 add(s:logs, printf("--- FAIL %s (%ss)", s:test[:-3], s:elapsed_time))
call extend(s:logs, map(v:errors, '" ". v:val'))
" reset so we can capture failures of next test
" Reset so we can capture failures of the next test.
let v:errors = []
else
call add(s:logs, printf("--- PASS: %s (%ss)", s:test[:-3], elapsed_time))
call add(s:logs, printf("--- PASS %s (%ss)", s:test[:-3], s:elapsed_time))
endif
endfor
" pop out into the scripts folder
execute cd . fnameescape(dir)
" create an empty fail to indicate that the test failed
" Create an empty fail to indicate that at least one test failed.
if s:fail > 0
split FAILED
write
split /tmp/vim-go-test/FAILED
silent write
endif
let total_elapsed_time = reltimestr(reltime(total_started))
let total_elapsed_time = substitute(total_elapsed_time, '^\s*\(.\{-}\)\s*$', '\1', '')
let s:total_elapsed_time = substitute(reltimestr(reltime(s:total_started)), '^\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
" Add all messages (usually errors).
redir => s:mess
silent messages
redir END
let s:logs = s:logs + filter(split(s:mess, "\n"), 'v:val !~ "^Messages maintainer"')
" also store all internal messages from s:logs: as well
split test.log
call append(line('$'), '')
call append(line('$'), 'From ' . g:testname . ':')
" Also store all internal messages from s:logs as well.
silent! split /tmp/vim-go-test/test.tmp
call append(line('$'), s:logs)
write
call append(line('$'), printf("%s%s %s / %s tests",
\ (s:fail > 0 ? 'FAIL ' : 'ok '),
\ s:testfile, s:total_elapsed_time, s:done))
silent! write
" bye, bye!
" Our work here is done.
qall!
" vim:ts=2:sts=2:sw=2:et