1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-24 06:20:05 +08:00
SpaceVim/bundle/neomake/tests/log.vader
2020-06-13 14:06:35 +08:00

42 lines
1.8 KiB
Plaintext
Vendored

Include: include/setup.vader
Execute (neomake#log#debug writes to logfile always):
Save g:neomake_verbose, g:neomake_logfile
let neomake_verbose = 0
let g:neomake_logfile = tempname()
call neomake#log#debug('msg1.')
call neomake#log#debug('msg2.')
if has('patch-7.4.503')
let logfile_msg = readfile(g:neomake_logfile)[1]
else
let logfile_msg = readfile(g:neomake_logfile)[0]
endif
" Also allow for small delay (on CI).
Assert logfile_msg =~# '\v\d\d:\d\d:\d\d \d+ \[D (\+0.0\d| )\] msg2.$', 'unexpected msg: '.logfile_msg
call neomake#log#debug('msg3.')
sleep 10m
call neomake#log#debug('msg4.', {})
let logfile_msg = readfile(g:neomake_logfile)[-1]
Assert logfile_msg =~# '\v\d\d:\d\d:\d\d \d+ \[D \+0.\d\d\] \[-.-:-:\d+\] msg4.$', 'Message does not match: '.logfile_msg
Execute (neomake#log#debug unsets logfile in case of errors):
Save g:neomake_logfile
let g:neomake_logfile = '/does/not/exist'
call neomake#log#debug('msg1.')
AssertNeomakeMessage '\vError when trying to write to logfile /does/not/exist: Vim\(call\):E.*. Unsetting g:neomake_logfile.', 0
Assert !exists('g:neomake_logfile'), 'g:neomake_logfile has been unset.'
Execute (neomake#log#debug is picky about punctuation):
call neomake#log#debug('msg1')
AssertEqual g:neomake_test_errors, ['Log msg does not end with punctuation: "msg1".']
let g:neomake_test_errors = []
Execute (neomake#log#debug throws with missing make_options in tests):
" Non-existing make_id should not make it verbose.
AssertEqual g:neomake_test_errors, []
call neomake#log#debug('msg1.', {'make_id': -42})
AssertEqual len(g:neomake_test_errors), 1
Assert g:neomake_test_errors[0] =~# '\v^GetMakeOptions failed: Vim\(let\):E716: Key not present in Dictionary: -42 \(in function .*\)$'
let g:neomake_test_errors = []