Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clojure-test: Exception report is not readable #67

Closed
frenchy64 opened this issue Apr 12, 2021 · 2 comments · Fixed by #74
Closed

clojure-test: Exception report is not readable #67

frenchy64 opened this issue Apr 12, 2021 · 2 comments · Fixed by #74

Comments

@frenchy64
Copy link
Contributor

frenchy64 commented Apr 12, 2021

Problem: when an exception occurs in checking, the resulting exception is not presented to the user in a readable format.

I believe the final argument to is needs a pr-str to print correctly here.

Without a pr-str, data like "" and nil print as nothing.

;; without pr-str
(clojure.test/is nil (ex-info "foo" {:a ""}))
;; FAIL in () (form-init9996546679642775017.clj:42)
;; #error {
;;  :cause foo
;;  :data {:a }
;;  :via
;;  [{:type clojure.lang.ExceptionInfo
;;    :message foo
;;    :data {:a }
;; with pr-str
(clojure.test/is nil (pr-str (ex-info "foo" {:a ""})))
;; FAIL in () (form-init9996546679642775017.clj:43)
;; #error {
;;  :cause "foo"
;;  :data {:a ""}
;;  :via
;;  [{:type clojure.lang.ExceptionInfo
;;    :message "foo"
;;    :data {:a ""}
@gfredericks
Copy link
Owner

Thenot-exception? part of the (is (not-exception? (:result result)) result) line makes me wonder if this could/should be simplified by using the new test.check key[s] that describe pass/fail using a boolean rather than the more ambiguous value-or-exception logic.

Anyhow, that's probably orthogonal to what's being pointed out here?

I have the vague notion that the second arg to is is supposed to be a string regardless, so in that respect your suggestion seems straightforwardly correct.

@frenchy64
Copy link
Contributor Author

frenchy64 commented Apr 18, 2021

... using the new test.check key[s] that describe pass/fail using a boolean rather than the more ambiguous value-or-exception logic.

Ah, yes. That behavior sounds much better. Orthogonal, but better. Opened #68.

This issue title more describes a fix than the problem. The problem is that the error report is not readable data, since "" and nil and such are lost. One fix is to use pr-str to report the exception. Another might be to find a prettier but also readable way to report this exception.

@frenchy64 frenchy64 changed the title clojure-test: Missing pr-str in exception reporting clojure-test: Exception report is not readable Apr 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants