From 03b805aee617f67eb7f33a54822bc76c23a2c5f5 Mon Sep 17 00:00:00 2001 From: Gregory Anders <8965202+gpanders@users.noreply.github.com> Date: Sat, 6 Nov 2021 08:26:10 -0600 Subject: feat(lua): enable stack traces in error output (#16228) --- test/helpers.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'test/helpers.lua') diff --git a/test/helpers.lua b/test/helpers.lua index 9ac3904776..09b113c01d 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -155,12 +155,20 @@ function module.pcall_err_withfile(fn, ...) return errmsg end -function module.pcall_err(fn, ...) +function module.pcall_err_withtrace(fn, ...) local errmsg = module.pcall_err_withfile(fn, ...) return errmsg:gsub('.../helpers.lua:0: ', '') end +function module.pcall_err(...) + return module.remove_trace(module.pcall_err_withtrace(...)) +end + +function module.remove_trace(s) + return (s:gsub("\n%s*stack traceback:.*", "")) +end + -- initial_path: directory to recurse into -- re: include pattern (string) -- exc_re: exclude pattern(s) (string or table) -- cgit