diff --git a/CHANGELOG.md b/CHANGELOG.md index 556748acc..f78020346 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ * [#546](https://github.com/clojure-emacs/cider-nrepl/pull/546): Added support for matcher-combinators to the test middleware. +### Changes + +* [#550](https://github.com/clojure-emacs/cider-nrepl/pull/550): Always return test documentation messages as strings. + ## 0.18.0 (2018-08-06) ### New features diff --git a/src/cider/nrepl/middleware/test.clj b/src/cider/nrepl/middleware/test.clj index 27e423048..39c7af79d 100644 --- a/src/cider/nrepl/middleware/test.clj +++ b/src/cider/nrepl/middleware/test.clj @@ -9,7 +9,8 @@ [orchard.namespace :as ns] [orchard.query :as query] [clojure.pprint :as pp] - [clojure.test :as test])) + [clojure.test :as test] + [clojure.walk :as walk])) (if (find-ns 'clojure.tools.nrepl) (require @@ -291,11 +292,18 @@ (with-interruptible-eval msg (try - (let [report (test-var-query - (-> var-query - (assoc-in [:ns-query :has-tests?] true) - (assoc :test? true) - (util.coerce/var-query)))] + (let [stringify-msg (fn [report] + (walk/postwalk (fn [x] (if (and (map? x) + (contains? x :message)) + (update x :message str) + x)) + report)) + report (-> var-query + (assoc-in [:ns-query :has-tests?] true) + (assoc :test? true) + (util.coerce/var-query) + test-var-query + stringify-msg)] (reset! results (:results report)) (t/send transport (response-for msg (u/transform-value report)))) (catch clojure.lang.ExceptionInfo e diff --git a/test/clj/cider/nrepl/middleware/test_filter_tests.clj b/test/clj/cider/nrepl/middleware/test_filter_tests.clj index 67edb7e18..10e5f3971 100644 --- a/test/clj/cider/nrepl/middleware/test_filter_tests.clj +++ b/test/clj/cider/nrepl/middleware/test_filter_tests.clj @@ -11,3 +11,6 @@ (deftest yet-an-other-test (is true "yet an other")) + +(deftest test-with-map-as-message + (is true {:key "val"})) diff --git a/test/clj/cider/nrepl/middleware/test_test.clj b/test/clj/cider/nrepl/middleware/test_test.clj index 6dcb5aea0..9b0086780 100644 --- a/test/clj/cider/nrepl/middleware/test_test.clj +++ b/test/clj/cider/nrepl/middleware/test_test.clj @@ -52,8 +52,8 @@ :exclude ["integration"]}) tests (keys (:cider.nrepl.middleware.test-filter-tests results))] (is ((set (keys results)) :cider.nrepl.middleware.test-filter-tests) "ns that contains smoke is present") - (is (= 2 (count tests)) "only one test was run") - (is (= #{:a-puff-of-smoke-test :yet-an-other-test} (set tests)) "only the test marked 'smoke' was run"))) + (is (= 3 (count tests)) "only one test was run") + (is (= #{:a-puff-of-smoke-test :yet-an-other-test :test-with-map-as-message} (set tests)) "only the test marked 'smoke' was run"))) (testing "marked test is still run if filter is not used" (let [{:keys [results] :as test-result} (session/message {:op "test" :ns "cider.nrepl.middleware.test-filter-tests"}) @@ -86,8 +86,8 @@ :exclude-meta-key ["integration"]}}) tests (keys (:cider.nrepl.middleware.test-filter-tests results))] (is ((set (keys results)) :cider.nrepl.middleware.test-filter-tests) "ns that contains smoke is present") - (is (= 2 (count tests)) "only one test was run") - (is (= #{:a-puff-of-smoke-test :yet-an-other-test} (set tests)) "only the test marked 'smoke' was run"))) + (is (= 3 (count tests)) "only one test was run") + (is (= #{:a-puff-of-smoke-test :yet-an-other-test :test-with-map-as-message} (set tests)) "only the test marked 'smoke' was run"))) (testing "marked test is still run if filter is not used" (let [{:keys [results] :as test-result} (session/message {:op "test-var-query" :var-query {:ns-query {:exactly ["cider.nrepl.middleware.test-filter-tests"]}}}) @@ -95,3 +95,14 @@ (is ((set (keys results)) :cider.nrepl.middleware.test-filter-tests) "ns that contains smoke is present") (is (< 1 (count tests)) "more tests were run") (is ((set tests) :a-puff-of-smoke-test) "smoke test is still present without a filter")))) + +(deftest run-test-with-map-as-documentation-message + (testing "documentation message map is returned as string" + (let [{:keys [results] :as test-result} (session/message {:op "test" + :ns "cider.nrepl.middleware.test-filter-tests" + :tests ["test-with-map-as-message"]})] + (is (= (str {:key "val"}) (-> results + :cider.nrepl.middleware.test-filter-tests + :test-with-map-as-message + first + :message))))))