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
parent
d911bc45fd
commit
4551fdcb28
|
@ -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
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ T{ test-failure
|
||||||
{ 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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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. ;
|
||||||
|
|
Loading…
Reference in New Issue