我相信这是“按设计进行”的,并且一些扩展 clojure.test
行为的工具依赖于此。 clojure.test
名称空间文档字符串有以下说明
SAVING TEST OUTPUT TO A FILE
All the test reporting functions write to the var *test-out*. By
default, this is the same as *out*, but you can rebind it to any
PrintWriter. For example, it could be a file opened with
clojure.java.io/writer.
有一个特定的用于测试报告器的 with-test-out
宏,它专门用于此目的,以便它们可以依赖此行为
(defmacro with-test-out
"Runs body with *out* bound to the value of *test-out*."
{:added "1.1"}
[& body]
`(binding [*out* *test-out*]
~@body))