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' } local bench_opts = { '-benchmem', '-cpuprofile', 'profile.out' }
M.efm = function() M.efm = function()
-- local indent = [[%\\%( %\\)]] local indent = [[%\\%( %\\)]]
local efm = [[%-G=== RUN %.%#]] local efm = [[%-G=== RUN %.%#]]
efm = efm .. [[,%-G" .. indent .. "%#--- PASS: %.%#]] efm = efm .. [[,%-G]] .. indent .. [[%#--- PASS: %.%#]]
efm = efm .. [[,%G--- FAIL: %\\%(Example%\\)%\\@=%m (%.%#)]] efm = efm .. [[,%G--- FAIL: %\\%(Example%\\)%\\@=%m (%.%#)]]
efm = efm .. [[,%G" .. indent .. "%#--- FAIL: %m (%.%#)]] efm = efm .. [[,%G]] .. indent .. [[%#--- FAIL: %m (%.%#)]]
efm = efm .. [[,%A" .. indent .. "%\\+%[%^:]%\\+: %f:%l: %m]] efm = efm .. [[,%A]] .. indent .. [[%\\+%[%^:]%\\+: %f:%l: %m]]
efm = efm .. [[,%+Gpanic: test timed out after %.%\\+]] efm = efm .. [[,%+Gpanic: test timed out after %.%\\+]]
efm = efm .. ',%+Afatal error: %.%# [recovered]' efm = efm .. ',%+Afatal error: %.%# [recovered]'
efm = efm .. [[,%+Afatal error: %.%#]] efm = efm .. [[,%+Afatal error: %.%#]]
efm = efm .. [[,%+Apanic: %.%#]] efm = efm .. [[,%+Apanic: %.%#]]
--
-- exit -- -- exit
efm = efm .. ',%-Cexit status %[0-9]%\\+' efm = efm .. ',%-Cexit status %[0-9]%\\+'
efm = efm .. ',exit status %[0-9]%\\+' efm = efm .. ',exit status %[0-9]%\\+'
-- failed lines -- -- failed lines
efm = efm .. ',%-CFAIL%\\t%.%#' efm = efm .. ',%-CFAIL%\\t%.%#'
efm = efm .. ',FAIL%\\t%.%#' efm = efm .. ',FAIL%\\t%.%#'
-- compiling error -- compiling error
efm = efm .. ',%A%f:%l:%c: %m' efm = efm .. ',%A%f:%l:%c: %m'
efm = efm .. ',%A%f:%l: %m' efm = efm .. ',%A%f:%l: %m'
efm = efm .. ',%G%\\t%m' efm = efm .. ',%f:%l +0x%[0-9A-Fa-f]%\\+' -- pannic with adress
efm = efm .. ',%-C%.%#' 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 = efm .. ',%-G%.%#'
efm = string.gsub(efm, ' ', [[\ ]]) efm = string.gsub(efm, ' ', [[\ ]])
-- log(efm) -- log(efm)
return efm return efm

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

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

Loading…
Cancel
Save