Clojure

clojure.test does not print ex-info in error reports

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code
  • Approval:
    Triaged

Description

clojure.test does not print the data attached to ExceptionInfo in error reports.

Approach: In clojure.stacktrace, which clojure.test uses for printing exceptions, add a check for ex-data and pr it.

Patch: 0002-CLJ-1209-show-ex-data-in-clojure-test.patch

Activity

Stuart Sierra made changes -
Field Original Value New Value
Description When clojure.test/deftest does error reports on unexpected exceptions it currently ignores ExceptionInfo and the valuable ex-data it carries. So this patch simple prints this data, it might be helpful to pprint or format it in another way but this was good enough for me.

See example from my tests: https://gist.github.com/thheller/5559391

{{clojure.test}} does not print the data attached to ExceptionInfo in error reports.

*Approach:* In {{clojure.stacktrace}}, which {{clojure.test}} uses for printing exceptions, add a check for {{ex-data}} and {{pr}} it.

*Patch:* 0002-CLJ-1209-show-ex-data-in-clojure-test.patch
Attachment 0002-CLJ-1209-show-ex-data-in-clojure-test.patch [ 12545 ]
Stuart Sierra made changes -
Summary Teach clojure.test reporting about ex-info/ex-data clojure.test does not print ex-info in error reports
Hide
Alex Miller added a comment -

Great idea, thx for the patch!

Show
Alex Miller added a comment - Great idea, thx for the patch!
Alex Miller made changes -
Approval Triaged [ 10120 ]
Hide
Alex Miller added a comment -

Would be great to see a before and after example of the output.

Show
Alex Miller added a comment - Would be great to see a before and after example of the output.
Alex Miller made changes -
Priority Trivial [ 5 ] Minor [ 4 ]
Hide
Ivan Kozik added a comment -

Attaching sample output

Show
Ivan Kozik added a comment - Attaching sample output
Ivan Kozik made changes -
Attachment output-with-0002-patch.txt [ 13128 ]
Alex Miller made changes -
Priority Minor [ 4 ] Major [ 3 ]
Hide
Stuart Sierra added a comment -

As pointed out on IRC, there's a possible risk of trying to print an infinite lazy sequence that happened to be included in ex-data.

To mitigate, consider binding *print-length* and *print-level* to small numbers around the call to pr.

Show
Stuart Sierra added a comment - As pointed out on IRC, there's a possible risk of trying to print an infinite lazy sequence that happened to be included in ex-data. To mitigate, consider binding *print-length* and *print-level* to small numbers around the call to pr.

People

Vote (2)
Watch (1)

Dates

  • Created:
    Updated: