Konrad Mrożek
2023-07-28 2f8117ea9542d0184948e01559c9219e1d5b829b
Fix exit code and use run-test-var from clojure 1.11
1 files modified
25 ■■■■■ changed files
clojure/src/test_runner.clj 25 ●●●●● patch | view | raw | blame | history
clojure/src/test_runner.clj
@@ -21,14 +21,14 @@
(defmethod vim-report :fail
  [m]
  (t/with-test-out
    (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")))
      (println (str "FAIL-CONTINUE:EXPECTED:" (pr-str (:expected m))))
      (println (str "FAIL-CONTINUE:ACTUAL:" (pr-str (:actual m)))))))
  (t/inc-report-counter :fail)
  (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")))
    (println (str "FAIL-CONTINUE:EXPECTED:" (pr-str (:expected m))))
    (println (str "FAIL-CONTINUE:ACTUAL:" (pr-str (:actual m))))))
(defn- find-line-number [source-file m]
  (if (instance? Throwable (:actual m))
@@ -44,6 +44,7 @@
(defmethod vim-report :error
  [m]
  (t/inc-report-counter :error)
  (when-let [source-file (some-> t/*testing-vars*
                                 first
                                 meta
@@ -101,8 +102,9 @@
        (with-redefs [t/report vim-report]
          (System/exit
           (if (pos? (if (and -test-file -test-line)
                       (let [results (t/test-vars [(find-closest-test (.. (java.io.File. -test-file) getAbsolutePath)
                                                                      (parse-long -test-line))])]
                       (let [results (t/run-test-var (find-closest-test (.. (java.io.File. -test-file) getAbsolutePath)
                                                                        (parse-long -test-line)))]
                         (+ (:fail results 0)
                            (:error results 0)))
                       (reduce (fn [total-fails n]
@@ -114,3 +116,6 @@
                               test-namespaces)))
             1
             0)))))))