2019-06-03 14:58:18 +00:00
" don't spam the user when Vim is started in Vi compatibility mode
let s :cpo_save = &cpo
set cpo &vim
2018-05-06 15:45:27 +00:00
func ! Test_Gometa ( ) abort
2019-06-03 14:58:18 +00:00
call s :gometa ( 'gometaliner' )
endfunc
func ! Test_GometaGolangciLint ( ) abort
call s :gometa ( 'golangci-lint' )
endfunc
func ! s :gometa ( metalinter ) abort
2018-05-06 15:45:27 +00:00
let $GOPATH = fnameescape ( fnamemodify ( getcwd ( ) , ':p' ) ) . 'test-fixtures/lint'
silent exe 'e ' . $GOPATH . '/src/lint/lint.go'
2019-06-03 14:58:18 +00:00
try
let g :go_metalinter_comand = a :metalinter
let expected = [
\ {'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-05-06 15:45:27 +00:00
2019-06-03 14:58:18 +00:00
" clear the quickfix lists
call setqflist ( [], 'r' )
2018-05-06 15:45:27 +00:00
2019-06-03 14:58:18 +00:00
let g :go_metalinter_enabled = ['golint' ]
2018-05-06 15:45:27 +00:00
2019-06-03 14:58:18 +00:00
call go #lint #Gometa ( 0 , 0 , $GOPATH . '/src/foo' )
2018-05-06 15:45:27 +00:00
let actual = getqflist ( )
2019-06-03 14:58:18 +00:00
let start = reltime ( )
while len ( actual ) = = 0 && reltimefloat ( reltime ( start ) ) < 10
sleep 100 m
let actual = getqflist ( )
endwhile
call gotest #assert_quickfix ( actual , expected )
finally
unlet g :go_metalinter_enabled
endtry
2018-05-06 15:45:27 +00:00
endfunc
func ! Test_GometaWithDisabled ( ) abort
2019-06-03 14:58:18 +00:00
call s :gometawithdisabled ( 'gometalinter' )
endfunc
func ! Test_GometaWithDisabledGolangciLint ( ) abort
call s :gometawithdisabled ( 'golangci-lint' )
endfunc
func ! s :gometawithdisabled ( metalinter ) abort
2018-05-06 15:45:27 +00:00
let $GOPATH = fnameescape ( fnamemodify ( getcwd ( ) , ':p' ) ) . 'test-fixtures/lint'
silent exe 'e ' . $GOPATH . '/src/lint/lint.go'
2019-06-03 14:58:18 +00:00
try
let g :go_metalinter_comand = a :metalinter
let expected = [
\ {'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-05-06 15:45:27 +00:00
2019-06-03 14:58:18 +00:00
" clear the quickfix lists
call setqflist ( [], 'r' )
2018-05-06 15:45:27 +00:00
2019-06-03 14:58:18 +00:00
let g :go_metalinter_disabled = ['vet' ]
2018-05-06 15:45:27 +00:00
2019-06-03 14:58:18 +00:00
call go #lint #Gometa ( 0 , 0 , $GOPATH . '/src/foo' )
2018-05-06 15:45:27 +00:00
let actual = getqflist ( )
2019-06-03 14:58:18 +00:00
let start = reltime ( )
while len ( actual ) = = 0 && reltimefloat ( reltime ( start ) ) < 10
sleep 100 m
let actual = getqflist ( )
endwhile
call gotest #assert_quickfix ( actual , expected )
finally
unlet g :go_metalinter_disabled
endtry
2018-05-06 15:45:27 +00:00
endfunc
func ! Test_GometaAutoSave ( ) abort
2019-06-03 14:58:18 +00:00
call s :gometaautosave ( 'gometalinter' )
endfunc
func ! Test_GometaAutoSaveGolangciLint ( ) abort
call s :gometaautosave ( 'golangci-lint' )
endfunc
func ! s :gometaautosave ( metalinter ) abort
2018-05-06 15:45:27 +00:00
let $GOPATH = fnameescape ( fnamemodify ( getcwd ( ) , ':p' ) ) . 'test-fixtures/lint'
silent exe 'e ' . $GOPATH . '/src/lint/lint.go'
2019-06-03 14:58:18 +00:00
try
let g :go_metalinter_comand = a :metalinter
let expected = [
\ {'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-05-06 15:45:27 +00:00
2019-06-03 14:58:18 +00:00
let winnr = winnr ( )
2018-05-06 15:45:27 +00:00
2019-06-03 14:58:18 +00:00
" clear the location lists
call setloclist ( l :winnr , [], 'r' )
2018-05-06 15:45:27 +00:00
2019-06-03 14:58:18 +00:00
let g :go_metalinter_autosave_enabled = ['golint' ]
2018-05-06 15:45:27 +00:00
2019-06-03 14:58:18 +00:00
call go #lint #Gometa ( 0 , 1 )
2018-05-06 15:45:27 +00:00
let actual = getloclist ( l :winnr )
2019-06-03 14:58:18 +00:00
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 )
finally
unlet g :go_metalinter_autosave_enabled
endtry
2018-05-06 15:45:27 +00:00
endfunc
2019-06-03 14:58:18 +00:00
func ! Test_Vet ( ) abort
2018-05-06 15:45:27 +00:00
let $GOPATH = fnameescape ( fnamemodify ( getcwd ( ) , ':p' ) ) . 'test-fixtures/lint'
silent exe 'e ' . $GOPATH . '/src/vet/vet.go'
compiler go
let expected = [
2019-06-03 14:58:18 +00:00
\ {'lnum' : 7 , 'bufnr' : bufnr ( '%' ) , 'col' : 2 , 'valid' : 1 , 'vcol' : 0 , 'nr' : -1 , 'type' : '' , 'pattern' : '' ,
\ 'text' : 'Printf format %d has arg str of wrong type string' }
2018-05-06 15:45:27 +00: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
2019-06-03 14:58:18 +00:00
" restore Vi compatibility settings
let &cpo = s :cpo_save
unlet s :cpo_save
2018-05-06 15:45:27 +00:00
" vim: sw=2 ts=2 et