From 96e0ce95b8b2e624267dc145055f829334d3072a Mon Sep 17 00:00:00 2001 From: ghthor Date: Fri, 26 Oct 2012 12:23:00 +0200 Subject: [PATCH] bugfix: use `go test` for test files. Test files are not compiled when invoking `go build`. --- syntax_checkers/go/go.vim | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/syntax_checkers/go/go.vim b/syntax_checkers/go/go.vim index 4bc2abe0..ead6ae6a 100644 --- a/syntax_checkers/go/go.vim +++ b/syntax_checkers/go/go.vim @@ -1,6 +1,6 @@ "============================================================================ "File: go.vim -"Description: Check go syntax using 'go build' +"Description: Check go syntax using 'go [build|test]' "Maintainer: Kamil Kisiel "License: This program is free software. It comes without any warranty, " to the extent permitted by applicable law. You can redistribute @@ -10,8 +10,14 @@ " "============================================================================ function! SyntaxCheckers_go_GetLocList() - let makeprg = 'go build -o /dev/null' - let errorformat = '%f:%l:%c:%m,%E%f:%l:%m,%C%m,%-G#%.%#' + " Test files, i.e. files with a name ending in `_test.go`, are not + " compiled by `go build`, therefore `go test` must be called for those. + if match(expand('%'), '_test.go$') == -1 + let makeprg = 'go build -o /dev/null' + else + let makeprg = 'go test -c -o /dev/null' + endif + let errorformat = '%f:%l:%c:%m,%f:%l%m,%-G#%.%#' " The go compiler needs to either be run with an import path as an " argument or directly from the package directory. Since figuring out