Skip to content

Commit

Permalink
Merge pull request #489 from NoahTheDuke/nb/clojure-1-10
Browse files Browse the repository at this point in the history
Update error handling to deal with Clojure 1.10 exception improvements
  • Loading branch information
philomates authored Jan 4, 2024
2 parents 5ce1022 + d7d17c7 commit 550b584
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
6 changes: 4 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
:description "A TDD library for Clojure that supports top-down ('mockish') TDD, encourages readable tests, provides a smooth migration path from clojure.test, balances abstraction and concreteness, and strives for graciousness."
:url "https://github.com/marick/Midje"
:pedantic? :warn
:dependencies [;; Note that in order to bump past Clojure 1.9.0 a test suite rehaul is needed given Clojure's improvements to macroexpansion errors
[org.clojure/clojure "1.9.0"]
:dependencies [[org.clojure/clojure "1.9.0"]
[marick/suchwow "6.0.3" :exclusions [org.clojure/clojure org.clojure/clojurescript]]
[org.clojure/math.combinatorics "0.2.0"]
[io.aviso/pretty "1.4.4" :exclusions [org.clojure/clojure]]
Expand All @@ -24,6 +23,9 @@
:1.7 [:test-libs {:dependencies [[org.clojure/clojure "1.7.0"]]}]
:1.8 [:test-libs {:dependencies [[org.clojure/clojure "1.8.0"]]}]
:1.9 [:test-libs {:dependencies [[org.clojure/clojure "1.9.0"]]}]
:1.10 [:test-libs {:dependencies [[org.clojure/clojure "1.10.3"]]}]
:1.11 [:test-libs {:dependencies [[org.clojure/clojure "1.11.1"]]}]
:1.12 [:test-libs {:dependencies [[org.clojure/clojure "1.12.0-alpha5"]]}]
;; The following profile can be used to check that `lein with-profile`
;; profiles are obeyed. Note that profile `:test-paths` *add on* to the
;; defaults.
Expand Down
11 changes: 7 additions & 4 deletions src/midje/checking/checkers/simple.clj
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,13 @@
;; Concerning Throwables

(letfn [(throwable-as-desired? [throwable desideratum]
(branch-on desideratum
fn? (desideratum throwable)
(some-fn string? regex?) (extended-= (.getMessage ^Throwable throwable) desideratum)
class? (instance? desideratum throwable)))]
;; Handle CompilerExceptions from 1.10+
(if (contains? (ex-data throwable) :clojure.error/phase)
(recur (.getCause throwable) desideratum)
(branch-on desideratum
fn? (desideratum throwable)
(some-fn string? regex?) (extended-= (.getMessage ^Throwable throwable) desideratum)
class? (instance? desideratum throwable))))]

(defchecker throws
"Checks for a thrown Throwable.
Expand Down
17 changes: 9 additions & 8 deletions src/midje/parsing/util/error_handling.clj
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@
(binding [*wrap-count* (inc *wrap-count*)]
(try
(parser)
(catch clojure.lang.ExceptionInfo ex
(if (= ::bail-out-of-parsing (-> ex ex-data :type))
false
(do
(report-exception ex)
false)))
(catch Exception ex
(report-exception ex)
false))))))
(let [;; Handle CompilerExceptions from 1.10+
ex (if (contains? (ex-data ex) :clojure.error/phase)
(.getCause ex)
ex)]
(if (= ::bail-out-of-parsing (-> ex ex-data :type))
false
(do
(report-exception ex)
false)))))))))



Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns implementation.parsing.util.fim_exception_line_numbers
(ns implementation.parsing.util.fim-exception-line-numbers
(:require [midje
[sweet :refer :all]
[test-util :refer :all]]))
Expand Down

0 comments on commit 550b584

Please sign in to comment.