Skip to content

Commit

Permalink
cmd: run tests only if the test file exists
Browse files Browse the repository at this point in the history
Closes #859
  • Loading branch information
fatih committed Jun 2, 2016
1 parent e6a7616 commit 8e0ea12
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions autoload/go/cmd.vim
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,18 @@ endfunction
function! go#cmd#Test(bang, compile, ...)
let args = ["test"]

" only run if the file exists
let test_file = expand('%')
if test_file =~# '^\f\+\.go$'
let l:root = split(test_file, ".go$")[0]
let l:alt_file = l:root . '_test.go'

if !filereadable(alt_file) && !bufexists(alt_file)
call go#util#EchoError("couldn't find ".alt_file)
return
endif
endif

" don't run the test, only compile it. Useful to capture and fix errors or
" to create a test binary.
if a:compile
Expand Down

0 comments on commit 8e0ea12

Please sign in to comment.