error format for panic in null-ls go tests

pull/277/head
ray-x 2 years ago
parent adab4c599d
commit ab678d7f42

@ -30,30 +30,34 @@ local short_opts = 'a:cC:t:bsFmpn:v'
local bench_opts = { '-benchmem', '-cpuprofile', 'profile.out' }
M.efm = function()
-- local indent = [[%\\%( %\\)]]
local indent = [[%\\%( %\\)]]
local efm = [[%-G=== RUN %.%#]]
efm = efm .. [[,%-G" .. indent .. "%#--- PASS: %.%#]]
efm = efm .. [[,%-G]] .. indent .. [[%#--- PASS: %.%#]]
efm = efm .. [[,%G--- FAIL: %\\%(Example%\\)%\\@=%m (%.%#)]]
efm = efm .. [[,%G" .. indent .. "%#--- FAIL: %m (%.%#)]]
efm = efm .. [[,%A" .. indent .. "%\\+%[%^:]%\\+: %f:%l: %m]]
efm = efm .. [[,%G]] .. indent .. [[%#--- FAIL: %m (%.%#)]]
efm = efm .. [[,%A]] .. indent .. [[%\\+%[%^:]%\\+: %f:%l: %m]]
efm = efm .. [[,%+Gpanic: test timed out after %.%\\+]]
efm = efm .. ',%+Afatal error: %.%# [recovered]'
efm = efm .. [[,%+Afatal error: %.%#]]
efm = efm .. [[,%+Apanic: %.%#]]
-- exit
--
-- -- exit
efm = efm .. ',%-Cexit status %[0-9]%\\+'
efm = efm .. ',exit status %[0-9]%\\+'
-- failed lines
-- -- failed lines
efm = efm .. ',%-CFAIL%\\t%.%#'
efm = efm .. ',FAIL%\\t%.%#'
-- compiling error
efm = efm .. ',%A%f:%l:%c: %m'
efm = efm .. ',%A%f:%l: %m'
efm = efm .. ',%G%\\t%m'
efm = efm .. ',%-C%.%#'
efm = efm .. ',%f:%l +0x%[0-9A-Fa-f]%\\+' -- pannic with adress
efm = efm .. ',%-G%\\t%\\f%\\+:%\\d%\\+ +0x%[0-9A-Fa-f]%\\+' -- test failure, address invalid inside
-- multi-line
efm = efm .. ',%+G%\\t%m'
efm = efm .. ',%-C%.%#' -- ignore rest of unmatched lines
efm = efm .. ',%-G%.%#'
efm = string.gsub(efm, ' ', [[\ ]])
-- log(efm)
return efm

@ -55,8 +55,8 @@ local function handler()
-- reset
output = ''
elseif entry.Action == 'fail' and vim.fn.empty(output) == 0 then
log(entry)
if filename:find(fn.expand('%:t')) then -- can be output from other files
-- log(entry)
if filename and filename:find(fn.expand('%:t')) then -- can be output from other files
table.insert(diags, {
file = filename,
row = tonumber(line),

@ -789,42 +789,49 @@ end
local namepath = {}
util.extract_filepath = function(msg)
msg = msg or ""
util.log(msg)
msg = msg or ''
-- util.log(msg)
--[[ or [[ findAllSubStr_test.go:234: Error inserting caseResult1: operation error DynamoDB: PutItem, exceeded maximum number of attempts]]
-- or 'path/path2/filename.go:50:11: Error xxx
-- or 'path/path2/filename.go:50:11: Error invaild
-- or /home/ray/go/src/github/sample/app/driver.go:342 +0x19e5
local pos, _ = msg:find([[[%w_-%./]+%.go:%d+:]])
if pos then
local pos2 = msg:find(":")
if not pos then
pos, _ = msg:find([[[%w_-%./]+%.go:%d+ ]]) -- test failure with panic
end
local pos2
if not pos then
return
end
pos2 = msg:find(':')
local s = msg:sub(1, pos2 - 1)
if vim.fn.filereadable(s) == 1 then
util.log('filename', s)
-- no need to extract path, already quickfix format
return
end
end
pos, _ = msg:find([[[%w_-]+_test%.go:%d+:]])
if pos == nil then
if not pos2 then
util.log('incorrect format', msg)
return
end
local pos2 = msg:find(":")
local pos2 = msg:find(':')
local s = msg:sub(pos, pos2 - 1)
util.log(s)
if namepath[s] ~= nil then
return namepath[s]
end
if vim.fn.filereadable(s) == 1 then
return
end
if vim.fn.executable("find") == 0 then
if vim.fn.executable('find') == 0 then
return
end
-- note: slow operations
local cmd = "find ./ -type f -name " .. s
local cmd = 'find ./ -type f -name ' .. s
local path = vim.fn.systemlist(cmd)
if vim.v.shell_error ~= 0 then
util.warn("find failed " .. cmd .. vim.inspect(path))
util.warn('find failed ' .. cmd .. vim.inspect(path))
return
end
for _, value in pairs(path) do
@ -839,5 +846,6 @@ util.extract_filepath = function(msg)
end
end
print(util.extract_filepath([[/home/ray/go/src/github/sample/app/driver.go:342 +0x19e5]]))
return util

Loading…
Cancel
Save