test(queries): print ALL errors at end

This commit is contained in:
Christian Clason 2024-01-04 19:18:49 +01:00
parent 1ae9b0e455
commit fc0fceb43a

View file

@ -51,7 +51,7 @@ local function do_check()
local query_types = queries.built_in_query_groups local query_types = queries.built_in_query_groups
local captures = extract_captures() local captures = extract_captures()
local last_error local errors = {}
io_print "::group::Check parsers" io_print "::group::Check parsers"
@ -66,8 +66,7 @@ local function do_check()
io_print("Checking " .. lang .. " " .. query_type .. string.format(" (%.02fms)", duration * 1e-6)) io_print("Checking " .. lang .. " " .. query_type .. string.format(" (%.02fms)", duration * 1e-6))
if not ok then if not ok then
local err_msg = lang .. " (" .. query_type .. "): " .. query local err_msg = lang .. " (" .. query_type .. "): " .. query
io_print(err_msg) errors[#errors + 1] = err_msg
last_error = err_msg
else else
if query then if query then
for _, capture in ipairs(query.captures) do for _, capture in ipairs(query.captures) do
@ -79,8 +78,7 @@ local function do_check()
) )
if not is_valid then if not is_valid then
local error = string.format("(x) Invalid capture @%s in %s for %s.", capture, query_type, lang) local error = string.format("(x) Invalid capture @%s in %s for %s.", capture, query_type, lang)
io_print(error) errors[#errors + 1] = error
last_error = error
end end
end end
end end
@ -90,10 +88,12 @@ local function do_check()
io_print "::endgroup::" io_print "::endgroup::"
if last_error then if #errors > 0 then
io_print() io_print "\nCheck failed!\nErrors:"
io_print "Last error: " for _, err in ipairs(errors) do
error(last_error) print(err)
end
error()
end end
return timings return timings
end end
@ -129,8 +129,5 @@ if ok then
io_print "Check successful!" io_print "Check successful!"
vim.cmd "q" vim.cmd "q"
else else
io_print "Check failed:"
io_print(result)
io_print "\n"
vim.cmd "cq" vim.cmd "cq"
end end