From d0939de548f49f9db017ce6dc0616ba1ed714490 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Wed, 17 Jun 2020 13:40:56 +0200 Subject: [PATCH] [#482] make clojure.test/report a dynamic var --- src/babashka/impl/test.clj | 9 +++++++-- test/babashka/test_test.clj | 7 +++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/babashka/impl/test.clj b/src/babashka/impl/test.clj index 497963eb..927d7a44 100644 --- a/src/babashka/impl/test.clj +++ b/src/babashka/impl/test.clj @@ -1,5 +1,9 @@ (ns babashka.impl.test - (:require [babashka.impl.clojure.test :as t])) + (:require [babashka.impl.clojure.test :as t] + [sci.core :as sci] + #_[sci.impl.namespaces :refer [copy-var]])) + +(def tns (sci/create-ns 'clojure.test nil)) (defn macrofy [v] (with-meta v {:sci/macro true})) @@ -20,7 +24,8 @@ 'testing-vars-str t/testing-vars-str 'testing-contexts-str t/testing-contexts-str 'inc-report-counter t/inc-report-counter - 'report t/report + 'report (sci/new-dynamic-var 'report t/report (assoc (meta t/report) + :ns tns)) 'do-report t/do-report ;; assertion utilities 'function? t/function? diff --git a/test/babashka/test_test.clj b/test/babashka/test_test.clj index eb6bc975..ffb320c1 100644 --- a/test/babashka/test_test.clj +++ b/test/babashka/test_test.clj @@ -1,9 +1,9 @@ (ns babashka.test-test (:require [babashka.test-utils :as tu] + [clojure.java.io :as io] [clojure.string :as str] - [clojure.test :as t :refer [deftest is]] - [clojure.java.io :as io])) + [clojure.test :as t :refer [deftest is]])) (defn bb [& args] (apply tu/bb nil (map str args))) @@ -69,3 +69,6 @@ (deftest assert-expr-test (is (str/includes? (bb (.getPath (io/file "test-resources" "babashka" "assert_expr.clj"))) "3.14 should be roughly 3.141592653589793"))) + +(deftest rebind-report-test + (is (bb "(binding [clojure.test/report (constantly true)] nil)")))