|
9 | 9 | [clojure.string :as str] |
10 | 10 | [clojure.test :as test] |
11 | 11 | [clojure.walk :as walk] |
12 | | - [haystack.analyzer :as stacktrace.analyzer] |
13 | | - [haystack.parser.clojure.throwable :as throwable] |
14 | 12 | [nrepl.middleware.interruptible-eval :as ie] |
15 | 13 | [nrepl.middleware.print :as print] |
16 | 14 | [nrepl.misc :refer [response-for]] |
17 | 15 | [nrepl.transport :as t] |
18 | 16 | [orchard.misc :as misc] |
19 | | - [orchard.query :as query])) |
| 17 | + [orchard.query :as query] |
| 18 | + [orchard.stacktrace :as stacktrace])) |
20 | 19 |
|
21 | 20 | ;;; ## Overview |
22 | 21 | ;; |
|
66 | 65 | (defn stack-frame |
67 | 66 | "Search the stacktrace of exception `e` for the function `f` and return info |
68 | 67 | describing the stack frame, including var, class, and line." |
69 | | - ([^Exception e f] |
70 | | - (stack-frame (stacktrace.analyzer/directory-namespaces) e f)) |
71 | | - ([namespaces ^Exception e f] |
72 | | - (when-let [class-name (some-> f class .getName)] |
73 | | - (->> e |
74 | | - .getStackTrace |
75 | | - (map throwable/StackTraceElement->vec) |
76 | | - (map (partial stacktrace.analyzer/analyze-frame namespaces)) |
77 | | - (filter |
78 | | - #(when-let [frame-cname (:class %)] |
79 | | - (when (string? frame-cname) |
80 | | - (str/starts-with? frame-cname class-name)))) |
81 | | - first)))) |
| 68 | + [^Exception e f] |
| 69 | + (when-let [class-name (some-> f class .getName)] |
| 70 | + (when-let [analyzed-trace (:stacktrace (first (stacktrace/analyze e)))] |
| 71 | + (some #(when-let [frame-cname (:class %)] |
| 72 | + (when (and (string? frame-cname) |
| 73 | + (str/starts-with? frame-cname class-name)) |
| 74 | + %)) |
| 75 | + analyzed-trace)))) |
82 | 76 |
|
83 | 77 | (defn- print-object |
84 | 78 | "Print `object` using println for matcher-combinators results and pprint |
|
260 | 254 | finds the erring test fixture in the stacktrace and binds it as the current |
261 | 255 | test var. Test count is decremented to indicate that no tests were run." |
262 | 256 | [ns e] |
263 | | - (let [namespaces (stacktrace.analyzer/directory-namespaces) |
264 | | - frame (->> (concat (:clojure.test/once-fixtures (meta ns)) |
| 257 | + (let [frame (->> (concat (:clojure.test/once-fixtures (meta ns)) |
265 | 258 | (:clojure.test/each-fixtures (meta ns))) |
266 | | - (map (partial stack-frame namespaces e)) |
267 | | - (filter identity) |
| 259 | + (keep #(stack-frame e %)) |
268 | 260 | (first)) |
269 | 261 | fixture (resolve (symbol (:var frame)))] |
270 | 262 | (swap! current-report update-in [:summary :test] dec) |
|
491 | 483 | (with-bindings (assoc @session #'ie/*msg* msg) |
492 | 484 | (let [[ns var] (map misc/as-sym [ns var])] |
493 | 485 | (if-let [e (get-in @results [ns var index :error])] |
494 | | - (doseq [cause (stacktrace.analyzer/analyze e print-fn)] |
| 486 | + (doseq [cause (stacktrace/analyze e print-fn)] |
495 | 487 | (t/send transport (response-for msg cause))) |
496 | 488 | (t/send transport (response-for msg :status :no-error)))))) |
497 | 489 | (fn [] |
|
0 commit comments