diff --git a/autoload/go/test.vim b/autoload/go/test.vim index 3cd53e900d..f73342aa00 100644 --- a/autoload/go/test.vim +++ b/autoload/go/test.vim @@ -253,28 +253,50 @@ endfunction function! s:parse_errors(lines) abort let errors = [] + let paniced = 0 " signals whether all remaining lines should be included in errors. " NOTE(arslan): once we get JSON output everything will be easier :) " https://github.com/golang/go/issues/2981 for line in a:lines - let fatalerrors = matchlist(line, '^\(fatal error:.*\)$') - let tokens = matchlist(line, '^\s*\(.\{-}\.go\):\(\d\+\):\s*\(.*\)') - + let fatalerrors = matchlist(line, '^\(\(fatal error\|panic\):.*\)$') if !empty(fatalerrors) - call add(errors, {"text": fatalerrors[1]}) - elseif !empty(tokens) + let paniced = 1 + call add(errors, {"text": line}) + continue + endif + + let tokens = [] + if paniced + let tokens = matchlist(line, '^\t\+\(.\{-}\.go\):\(\d\+\) \(+0x.*\)') + else + let tokens = matchlist(line, '^ *\t\+\(.\{-}\.go\):\(\d\+\):\s*\(.*\)') + endif + + if !empty(tokens) " Check whether the line may refer to a file. " strip endlines of form ^M let out = substitute(tokens[3], '\r$', '', '') + let file = fnamemodify(tokens[1], ':p') + + " Preserve the line when the filename is not readable. This is an + " unusual case, but possible; any test that produces lines that match + " the pattern used in the matchlist assigned to tokens is a potential + " source of this condition. For instance, github.com/golang/mock/gomock + " will sometimes produce lines that satisfy this condition. + if !filereadable(file) + call add(errors, {"text": line}) + continue + endif call add(errors, { - \ "filename" : fnamemodify(tokens[1], ':p'), + \ "filename" : file, \ "lnum" : tokens[2], \ "text" : out, \ }) + elseif paniced + call add(errors, {"text": line}) elseif !empty(errors) - " Preserve indented lines. - " This comes up especially with multi-line test output. - if match(line, '^\s') >= 0 + " Preserve indented lines. This comes up especially with multi-line test output. + if match(line, '^ *\t\+') >= 0 call add(errors, {"text": line}) endif endif