From 04e87458effac590286133b497f25ae6eeb1e6ba Mon Sep 17 00:00:00 2001 From: Konrad Mrożek <konrad.mrozek@shareablee.com> Date: Tue, 06 Jun 2023 15:12:08 +0000 Subject: [PATCH] Set new reporting output and handle with errorformat --- clojure/src/test_runner.clj | 30 +++++++++++++++++++++++++++--- 1 files changed, 27 insertions(+), 3 deletions(-) diff --git a/clojure/src/test_runner.clj b/clojure/src/test_runner.clj index 2868c26..b38513b 100644 --- a/clojure/src/test_runner.clj +++ b/clojure/src/test_runner.clj @@ -9,10 +9,25 @@ (defmulti emacs-report :type) -(defmethod emacs-report :pass +(defmethod emacs-report :fail [m] (t/with-test-out - (println "PASS:"))) + (when-let [source-file (some-> t/*testing-vars* + first + meta + :file)] + (println (str "FAIL:" source-file ":" (:line m) ":" (t/testing-vars-str m) ":" (t/testing-contexts-str) ":" (:message m "FAIL")))))) + +(defmethod emacs-report :error + [m] + (when-let [source-file (some-> t/*testing-vars* + first + meta + :file)] + (println (str "ERROR:" source-file ":" (:line m) ":" (t/testing-vars-str m) ":" (t/testing-contexts-str) ":" (:message m "FAIL"))))) + +(defmethod emacs-report :default + [_]) (defn -main [& [test-file]] (binding [*compile-files* true] @@ -25,4 +40,13 @@ (map load-file) (map (comp :ns meta)) (into #{}))] - (run! (fn [n] (t/run-tests n)) test-namespaces)))) + (System/exit (if (pos? (reduce (fn [total-fails n] + (with-redefs [t/report emacs-report] + (let [results (t/run-tests n)] + (+ total-fails + (:fail results 0) + (:error results 0))))) + 0 + test-namespaces)) + 1 + 0))))) -- Gitblit v1.9.3