Why is my `with-redefs-fn` rebinding ignored?

394 views Asked by At

I am attempting to replace the stacktrace-file-and-line (private) function in clojure.test, but using with-redefs-fn when running tests seems to have no effect. When I execute the following code the original stacktrace-file-and-line is called instead of my anonymous function.

(with-redefs-fn 
 {#'clojure.test/stacktrace-file-and-line (fn [stacktrace] {:file "foo.clj" :line 1})}
 #(clojure.test/run-tests 'repl-test.core-test))

Does with-redefs-fn not work with private function or is there something about the clojure.test namespace that is preventing this from working?

1

There are 1 answers

2
Piotrek Bzdyl On BEST ANSWER

I suspect that clojure.test is compiled with direct linking and thus causing that with-redefs-fn and with-redefs won't work.