2018-02-04 06:35:08 -05:00
func ! Test_Gometa ( ) abort
let $GOPATH = fnameescape ( fnamemodify ( getcwd ( ) , ':p' ) ) . 'test-fixtures/lint'
silent exe 'e ' . $GOPATH . '/src/lint/lint.go'
let expected = [
2018-03-31 10:56:26 -04:00
\ {'lnum' : 5 , 'bufnr' : bufnr ( '%' ) + 1 , 'col' : 1 , 'valid' : 1 , 'vcol' : 0 , 'nr' : -1 , 'type' : 'w' , 'pattern' : '' , 'text' : 'exported function MissingFooDoc should have comment or be unexported (golint)' }
2018-02-04 06:35:08 -05:00
\ ]
" clear the quickfix lists
call setqflist ( [], 'r' )
" call go#lint#ToggleMetaLinterAutoSave from lint.vim so that the file will
" be autoloaded and the default for g:go_metalinter_enabled will be set so
" we can capture it to restore it after the test is run.
2018-06-14 06:31:12 -04:00
silent call go #lint #ToggleMetaLinterAutoSave ( )
2018-02-04 06:35:08 -05:00
" And restore it back to its previous value
2018-06-14 06:31:12 -04:00
silent call go #lint #ToggleMetaLinterAutoSave ( )
2018-02-04 06:35:08 -05:00
let g :go_metalinter_enabled = ['golint' ]
call go #lint #Gometa ( 0 , $GOPATH . '/src/foo' )
let actual = getqflist ( )
let start = reltime ( )
while len ( actual ) = = 0 && reltimefloat ( reltime ( start ) ) < 10
sleep 100 m
let actual = getqflist ( )
endwhile
call gotest #assert_quickfix ( actual , expected )
2018-06-14 06:31:12 -04:00
unlet g :go_metalinter_enabled
2018-02-04 06:35:08 -05:00
endfunc
func ! Test_GometaWithDisabled ( ) abort
let $GOPATH = fnameescape ( fnamemodify ( getcwd ( ) , ':p' ) ) . 'test-fixtures/lint'
silent exe 'e ' . $GOPATH . '/src/lint/lint.go'
let expected = [
2018-03-31 10:56:26 -04:00
\ {'lnum' : 5 , 'bufnr' : bufnr ( '%' ) + 1 , 'col' : 1 , 'valid' : 1 , 'vcol' : 0 , 'nr' : -1 , 'type' : 'w' , 'pattern' : '' , 'text' : 'exported function MissingFooDoc should have comment or be unexported (golint)' }
2018-02-04 06:35:08 -05:00
\ ]
" clear the quickfix lists
call setqflist ( [], 'r' )
" call go#lint#ToggleMetaLinterAutoSave from lint.vim so that the file will
" be autoloaded and the default for g:go_metalinter_disabled will be set so
" we can capture it to restore it after the test is run.
2018-06-14 06:31:12 -04:00
silent call go #lint #ToggleMetaLinterAutoSave ( )
2018-02-04 06:35:08 -05:00
" And restore it back to its previous value
2018-06-14 06:31:12 -04:00
silent call go #lint #ToggleMetaLinterAutoSave ( )
2018-02-04 06:35:08 -05:00
let g :go_metalinter_disabled = ['vet' ]
call go #lint #Gometa ( 0 , $GOPATH . '/src/foo' )
let actual = getqflist ( )
let start = reltime ( )
while len ( actual ) = = 0 && reltimefloat ( reltime ( start ) ) < 10
sleep 100 m
let actual = getqflist ( )
endwhile
call gotest #assert_quickfix ( actual , expected )
2018-06-14 06:31:12 -04:00
unlet g :go_metalinter_disabled
2018-02-04 06:35:08 -05:00
endfunc
func ! Test_GometaAutoSave ( ) abort
let $GOPATH = fnameescape ( fnamemodify ( getcwd ( ) , ':p' ) ) . 'test-fixtures/lint'
silent exe 'e ' . $GOPATH . '/src/lint/lint.go'
let expected = [
2018-03-31 10:56:26 -04:00
\ {'lnum' : 5 , 'bufnr' : bufnr ( '%' ) , 'col' : 1 , 'valid' : 1 , 'vcol' : 0 , 'nr' : -1 , 'type' : 'w' , 'pattern' : '' , 'text' : 'exported function MissingDoc should have comment or be unexported (golint)' }
2018-02-04 06:35:08 -05:00
\ ]
let winnr = winnr ( )
" clear the location lists
call setloclist ( l :winnr , [], 'r' )
" call go#lint#ToggleMetaLinterAutoSave from lint.vim so that the file will
" be autoloaded and the default for g:go_metalinter_autosave_enabled will be
" set so we can capture it to restore it after the test is run.
2018-06-14 06:31:12 -04:00
silent call go #lint #ToggleMetaLinterAutoSave ( )
2018-02-04 06:35:08 -05:00
" And restore it back to its previous value
2018-06-14 06:31:12 -04:00
silent call go #lint #ToggleMetaLinterAutoSave ( )
2018-02-04 06:35:08 -05:00
let g :go_metalinter_autosave_enabled = ['golint' ]
call go #lint #Gometa ( 1 )
let actual = getloclist ( l :winnr )
let start = reltime ( )
while len ( actual ) = = 0 && reltimefloat ( reltime ( start ) ) < 10
sleep 100 m
let actual = getloclist ( l :winnr )
endwhile
call gotest #assert_quickfix ( actual , expected )
2018-06-14 06:31:12 -04:00
unlet g :go_metalinter_autosave_enabled
2018-02-04 06:35:08 -05:00
endfunc
2018-03-31 10:56:26 -04:00
func ! Test_Vet ( )
let $GOPATH = fnameescape ( fnamemodify ( getcwd ( ) , ':p' ) ) . 'test-fixtures/lint'
silent exe 'e ' . $GOPATH . '/src/vet/vet.go'
compiler go
let expected = [
2018-06-14 06:31:12 -04:00
\ {'lnum' : 7 , 'bufnr' : bufnr ( '%' ) , 'col' : 0 , 'valid' : 1 , 'vcol' : 0 , 'nr' : -1 , 'type' : '' , 'pattern' : '' ,
\ 'text' : 'Printf format %d has arg str of wrong type string' }
2018-03-31 10:56:26 -04:00
\ ]
let winnr = winnr ( )
" clear the location lists
call setqflist ( [], 'r' )
call go #lint #Vet ( 1 )
let actual = getqflist ( )
let start = reltime ( )
while len ( actual ) = = 0 && reltimefloat ( reltime ( start ) ) < 10
sleep 100 m
let actual = getqflist ( )
endwhile
call gotest #assert_quickfix ( actual , expected )
endfunc
2018-02-04 06:35:08 -05:00
" vim: sw=2 ts=2 et