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

View File

@ -1,8 +1,20 @@
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 } [
[
[ "OOPS" ] must-fail
] fake-unit-test length
] 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 ]
[ asset>> [ experiment. nl ] when* ]
[ error>> error. ]
[ continuation>> traceback-link. ]
[ continuation>> call>> callstack. ]
} cleave ;
: :test-failures ( -- ) test-failures get errors. ;