Skip to content
Snippets Groups Projects
Unverified Commit ad69111e authored by Cam Saul's avatar Cam Saul Committed by GitHub
Browse files

Minor test runner/config fixes (#17323)

* Fix JUnit output not correctly stripping ANSI color codes

* Remove find-tests profiling log message

* 1-arg arity of metabase.test-runner/run

* Fix bug with metabase.test-runner/find-tests with a single test name
parent 089e02dd
No related merge requests found
......@@ -40,7 +40,7 @@
(qp.streaming/streaming-response 1)
(prop/for-all 1)
(tools.macro/macrolet '(1 (:defn))))))
(cider-clojure-cli-aliases . "dev:drivers:drivers-dev:ee:ee-dev:build:user")
(cider-clojure-cli-aliases . "dev:drivers:drivers-dev:ee:ee-dev:user")
(clojure-indent-style . always-align)
;; if you're using clj-refactor (highly recommended!)
(cljr-favor-prefix-notation . nil)
......
......@@ -16,7 +16,6 @@
[metabase.test-runner.parallel :as parallel]
[metabase.test.data.env :as tx.env]
metabase.test.redefs
[metabase.util :as u]
[pjstadig.humane-test-output :as humane-test-output]))
;; initialize Humane Test Output if it's not already initialized.
......@@ -70,13 +69,18 @@
;; a test namespace or individual test
(defmethod find-tests clojure.lang.Symbol
[symb]
(if (namespace symb)
;; a actual test var e.g. `metabase.whatever-test/my-test`
[symb]
;; a namespace e.g. `metabase.whatever-test`
(binding [init/*test-namespace-being-loaded* symb]
(require symb)
(eftest.runner/find-tests symb))))
(letfn [(load-test-namespace [ns-symb]
(binding [init/*test-namespace-being-loaded* ns-symb]
(require ns-symb)))]
(if-let [symbol-namespace (some-> (namespace symb) symbol)]
;; a actual test var e.g. `metabase.whatever-test/my-test`
(do
(load-test-namespace symbol-namespace)
[(resolve symb)])
;; a namespace e.g. `metabase.whatever-test`
(do
(load-test-namespace symb)
(eftest.runner/find-tests symb)))))
;; default -- look in all dirs on the classpath
(defmethod find-tests nil
......@@ -86,7 +90,7 @@
(defn tests [{:keys [only]}]
(when only
(println "Running tests in" (pr-str only)))
(let [tests (u/profile "Find tests" (find-tests only))]
(let [tests (find-tests only)]
(println "Running" (count tests) "tests")
tests))
......@@ -117,22 +121,25 @@
"Run `test-vars` with `options`, which are passed directly to [[eftest.runner/run-tests]].
;; run tests in a single namespace
(run (find-tests 'metabase.bad-test) nil)
(run (find-tests 'metabase.bad-test))
;; run tests in a directory
(run (find-tests \"test/metabase/query_processor_test\") nil)"
[test-vars options]
;; don't randomize test order for now please, thanks anyway
(with-redefs [eftest.runner/deterministic-shuffle (fn [_ test-vars] test-vars)]
(eftest.runner/run-tests
test-vars
(merge
{:capture-output? false
;; parallel tests disabled for the time being -- some tests randomly fail if the data warehouse connection pool
;; gets nuked by a different thread. Once we fix that we can re-enable parallel tests.
:multithread? false #_:vars
:report (reporter)}
options))))
(run (find-tests \"test/metabase/query_processor_test\"))"
([test-vars]
(run test-vars nil))
([test-vars options]
;; don't randomize test order for now please, thanks anyway
(with-redefs [eftest.runner/deterministic-shuffle (fn [_ test-vars] test-vars)]
(eftest.runner/run-tests
test-vars
(merge
{:capture-output? false
;; parallel tests disabled for the time being -- some tests randomly fail if the data warehouse connection pool
;; gets nuked by a different thread. Once we fix that we can re-enable parallel tests.
:multithread? false #_:vars
:report (reporter)}
options)))))
;;;; `clojure -X` entrypoint
......
......@@ -42,9 +42,9 @@
(defn- print-result-description [{:keys [file line message testing-contexts], :as result}]
(println (format "%s:%d" file line))
(doseq [s (reverse testing-contexts)]
(println (str/trim (escape-unprintable-characters s))))
(println (str/trim (decolorize-and-escape s))))
(when message
(println (escape-unprintable-characters message))))
(println (decolorize-and-escape message))))
(defn- print-expected [expected actual]
(p/rprint "expected: ")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment