Fix tests

This commit is contained in:
Michiel Borkent 2022-10-03 15:34:47 +02:00
parent 80a8ee1b7e
commit 2b3e7df2e9

View file

@ -1,13 +1,17 @@
(ns babashka.run-all-libtests (ns babashka.run-all-libtests
(:require [babashka.classpath :as cp :refer [add-classpath]] (:require
[babashka.classpath :as cp :refer [add-classpath]]
[babashka.core :refer [windows?]] [babashka.core :refer [windows?]]
[babashka.fs :as fs] [babashka.fs :as fs]
[clojure.edn :as edn] [clojure.edn :as edn]
[clojure.java.io :as io] [clojure.java.io :as io]
[clojure.test :as t :refer [*report-counters*]] [clojure.spec.test.alpha :as st]
[clojure.string :as str])) [clojure.string :as str]
[clojure.test :as t :refer [*report-counters*]]))
(defmethod clojure.test/report :end-test-var [_m] (def orig-spec-checking-fn @#'st/spec-checking-fn)
(defmethod t/report :end-test-var [_m]
(when-let [rc *report-counters*] (when-let [rc *report-counters*]
(let [{:keys [:fail :error]} @rc] (let [{:keys [:fail :error]} @rc]
(when (and (= "true" (System/getenv "BABASHKA_FAIL_FAST")) (when (and (= "true" (System/getenv "BABASHKA_FAIL_FAST"))
@ -35,17 +39,19 @@
(defn test-namespaces [& namespaces] (defn test-namespaces [& namespaces]
(let [namespaces (seq (filter test-namespace? namespaces))] (let [namespaces (seq (filter test-namespace? namespaces))]
(when (seq namespaces) (when (seq namespaces)
(let [no-orch-namespaces (remove #(str/starts-with? (str %) "orchestra") namespaces) (let [namespaces namespaces]
;; somehow orchestra screws up other tests, so we run that last
orch-namespaces (filter #(str/starts-with? (str %) "orchestra") namespaces)
namespaces (concat no-orch-namespaces orch-namespaces)]
(doseq [n namespaces] (doseq [n namespaces]
(let [orchestra? (str/starts-with? (str n) "orchestra")]
(if orchestra?
nil ;; (alter-var-root #'st/spec-checking-fn (constantly ot/spec-checking-fn))
(alter-var-root #'st/spec-checking-fn (constantly orig-spec-checking-fn)))
(when-not orchestra?
(require n) (require n)
(filter-vars! (find-ns n) #(-> % meta ((some-fn :skip-bb (filter-vars! (find-ns n) #(-> % meta ((some-fn :skip-bb
:test-check-slow)) not)) :test-check-slow)) not))
(let [m (apply t/run-tests [n])] (let [m (apply t/run-tests [n])]
(swap! status (fn [status] (swap! status (fn [status]
(merge-with + status (dissoc m :type)))))))))) (merge-with + status (dissoc m :type))))))))))))
;; Standard test-runner for libtests ;; Standard test-runner for libtests
(let [lib-tests (edn/read-string (slurp (io/resource "bb-tested-libs.edn"))) (let [lib-tests (edn/read-string (slurp (io/resource "bb-tested-libs.edn")))