print exception for tests (if occur or -v)

This commit is contained in:
Denis Knauf 2021-12-09 14:11:45 +01:00
parent ec025652c9
commit 7078305256

View file

@ -41,6 +41,11 @@ class Capture
STDERR.printf "[% 4d] \e[1;31mer\e[0m %s tests %s\e[J\n", @counter, $0.shellescape, command.shelljoin
end
def logexception prefix, exception
loginfo "#{prefix} (#{exception.class.name}) #{exception}"
exception.backtrace[0...-Kernel.caller.length].each {|l| loginfo " #{l}" }
end
def loginfo text
STDERR.printf " %s\n", text
end
@ -64,7 +69,7 @@ class Capture
end
rescue Object
logfail command
loginfo "unexpected raise: (#{$!.class.name}) #$!"
logexception "unexpected raise:", $!
STDERR.puts
end
@ -76,16 +81,16 @@ class Capture
if message === $!.message
logok command
if @verbose
loginfo "raised: (#{$!.class.name}) #$!"
logexception "raised:", $!
STDERR.puts
end
else
loginfo "unexpected message: (#{$!.class.name}) #$!"
logexception "unexpected message:", $!
STDERR.puts
end
rescue Object
logfail command
loginfo "unexpected raised: (#{$!.class.name}) #$!"
logexception "unexpected raised:", $!
STDERR.puts
end
end