From cb0f60d743fb4a5420d1e6cca0404507c4e50642 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Fri, 23 Nov 2018 17:41:41 +0100 Subject: test script tweaks --- tests/error.lua | 23 +++++++++++++++++------ tests/linda_perf.lua | 2 +- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/tests/error.lua b/tests/error.lua index 91015d8..91ccebc 100644 --- a/tests/error.lua +++ b/tests/error.lua @@ -4,10 +4,10 @@ -- Note: this code is supposed to end in errors; not included in 'make test' -- -local lanes = require "lanes".configure() - -local function lane() +local lanes = require "lanes".configure{ with_timers = false} +local function lane( mode_) + set_error_reporting( mode_) local subf= function() -- this so that we can see the call stack error "aa" --error({}) @@ -27,20 +27,31 @@ local lgen = lanes.gen("*", { --[[finalizer=cleanup]] }, lane) --- io.stderr:write( "\n** Error catching **\n" ) -- -local h= lgen() + +local error_reporting_mode = "extended" +local h= lgen( error_reporting_mode) local _,err,stack= h:join() -- wait for the lane (no automatic error propagation) if err then assert( type(stack)=="table" ) -- only true if lanes was compiled with ERROR_FULL_STACK == 1 io.stderr:write( "Lane error: "..tostring(err).."\n" ) - io.stderr:write( "\t", table.concat(stack,"\n\t"), "\n" ); + if error_reporting_mode == "basic" then -- each stack line is a string in basic mode + io.stderr:write( "\t", table.concat(stack,"\n\t"), "\n" ); + else -- each stack line is a table in extended mode + for line, details in pairs( stack) do + io.stderr:write( "\t", tostring( line), "\n" ); + for detail, value in pairs( details) do + io.stderr:write( "\t\t", tostring( detail), ":", tostring( value), "\n") + end + end + end end --- io.stderr:write( "\n** Error propagation **\n" ) -- -local h2= lgen() +local h2= lgen( error_reporting_mode) local _= h2[0] assert(false) -- does NOT get here diff --git a/tests/linda_perf.lua b/tests/linda_perf.lua index 1a44d07..fa2d633 100644 --- a/tests/linda_perf.lua +++ b/tests/linda_perf.lua @@ -1,5 +1,5 @@ local lanes = require "lanes" -lanes.configure() +lanes.configure{ with_timers = false} -- Lua 5.1/5.2 compatibility local table_unpack = unpack or table.unpack -- cgit v1.2.3-55-g6feb