Skip to content

Commit 1e88bcb

Browse files
vemvbbatsov
authored andcommitted
Introduce deftest stack-frame-test
1 parent 4726ea9 commit 1e88bcb

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

test/clj/cider/nrepl/middleware/test_test.clj

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
;; Ensure tested tests are loaded:
55
cider.nrepl.middleware.test-filter-tests
66
[cider.nrepl.test-session :as session]
7-
[clojure.test :refer :all]))
7+
[clojure.test :refer :all])
8+
(:import
9+
(clojure.lang ExceptionInfo)))
810

911
(use-fixtures :each session/session-fixture)
1012

@@ -165,3 +167,29 @@
165167
:actual exception}))
166168
(is (= [exception]
167169
@proof))))))
170+
171+
(defn throws []
172+
(throw (ex-info "." {})))
173+
174+
(defn comparable-stack-frame
175+
"A stack-frame map without varying parts that make testing more cumbersome."
176+
[stack-frame]
177+
(dissoc stack-frame :file-url :line))
178+
179+
(deftest stack-frame-test
180+
(let [e (try
181+
(throws)
182+
(catch ExceptionInfo e
183+
e))]
184+
(is (= {:fn "throws"
185+
:method "invokeStatic"
186+
:ns "cider.nrepl.middleware.test-test"
187+
:name "cider.nrepl.middleware.test_test$throws/invokeStatic"
188+
:file "test_test.clj"
189+
:type :clj
190+
:var "cider.nrepl.middleware.test-test/throws"
191+
:class "cider.nrepl.middleware.test_test$throws"
192+
:flags #{:project :clj}}
193+
(comparable-stack-frame (test/stack-frame e throws)))
194+
"Returns a map representing the stack frame of the precise function
195+
that threw the exception")))

0 commit comments

Comments
 (0)