tools.test: print the callstack in test failures

So when mason reports a test failure it should include the whole
callstack. That should make it easier to catch the "No suitable
arithmetic method" random error that is hard to debug without a
callstack.
db4
Björn Lindqvist 2015-12-03 12:00:40 +01:00
parent d911bc45fd
commit 4551fdcb28
3 changed files with 45 additions and 33 deletions

View File

@ -1,4 +1,4 @@
USING: accessors alien.syntax continuations debugger kernel USING: accessors alien.syntax continuations debugger kernel literals
namespaces tools.test ; namespaces tools.test ;
IN: debugger.tests IN: debugger.tests
@ -8,36 +8,36 @@ IN: debugger.tests
{ f } [ { "A" "B" } vm-error? ] unit-test { f } [ { "A" "B" } vm-error? ] unit-test
{ } [ { } [
T{ test-failure T{ test-failure
{ error { error
{ {
"kernel-error" "kernel-error"
10 10
{ {
B{ B{
88 73 110 112 117 116 69 110 97 98 108 101 0 88 73 110 112 117 116 69 110 97 98 108 101 0
} }
B{ B{
88 73 110 112 117 116 69 110 97 98 108 101 88 73 110 112 117 116 69 110 97 98 108 101
64 56 0 64 56 0
} }
B{ B{
95 88 73 110 112 117 116 69 110 97 98 108 95 88 73 110 112 117 116 69 110 97 98 108
101 64 56 0 101 64 56 0
} }
B{ B{
64 88 73 110 112 117 116 69 110 97 98 108 64 88 73 110 112 117 116 69 110 97 98 108
101 64 56 0 101 64 56 0
} }
} }
DLL" xinput1_3.dll" DLL" xinput1_3.dll"
} }
} }
{ asset { "Unit Test" [ ] [ dup ] } } { asset { "Unit Test" [ ] [ dup ] } }
{ path "resource:basis/game/input/input-tests.factor" } { path "resource:basis/game/input/input-tests.factor" }
{ line# 6 } { line# 6 }
{ continuation f } { continuation $[ current-continuation ] }
} error. } error.
] unit-test ] unit-test
{ "foo" { 1 2 3 "foo" } } [ { "foo" { 1 2 3 "foo" } } [

View File

@ -1,8 +1,20 @@
IN: tools.test.tests IN: tools.test.tests
USING: tools.test tools.test.private namespaces kernel sequences ; USING: continuations debugger io.streams.string kernel namespaces
sequences tools.test tools.test.private ;
{ 1 } [ { 1 } [
[ [
[ "OOPS" ] must-fail [ "OOPS" ] must-fail
] fake-unit-test length ] fake-unit-test length
] unit-test ] unit-test
: create-test-failure ( -- error )
[ "hello" throw ] [
f "path" 25 error-continuation get test-failure boa
] recover ;
! Just verifies that the presented output contains a callstack.
{ t } [
create-test-failure [ error. ] with-string-writer
"OBJ-CURRENT-THREAD" swap subseq?
] unit-test

View File

@ -161,7 +161,7 @@ M: test-failure error. ( error -- )
[ error-location print nl ] [ error-location print nl ]
[ asset>> [ experiment. nl ] when* ] [ asset>> [ experiment. nl ] when* ]
[ error>> error. ] [ error>> error. ]
[ continuation>> traceback-link. ] [ continuation>> call>> callstack. ]
} cleave ; } cleave ;
: :test-failures ( -- ) test-failures get errors. ; : :test-failures ( -- ) test-failures get errors. ;