Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

module test runner (#69124)

dpsuttonb5ef6e1d0ca1
diff --git a/test/metabase/test_runner.clj b/test/metabase/test_runner.clj
index b93dc584f9d..c7b6cc5a813 100644
--- a/test/metabase/test_runner.clj
+++ b/test/metabase/test_runner.clj
@@ -92,12 +92,35 @@
:exclude-directories excluded-directories
:test-warn-time 3000})
+(defn module-folders
+ [modules]
+ (letfn [(n [m] (str/replace (name m) \- \_))]
+ (for [m modules]
+ (if (= "enterprise" (namespace m))
+ (str "enterprise/backend/test/metabase_enterprise/" (n m))
+ (str "test/metabase/" (n m))))))
+
+(defn parse-options
+ [options]
+ (let [base (merge (default-options) options)]
+ (cond-> base
+ (or (:modules options) (:module options))
+ (-> (assoc :only (let [modules (cond-> #{}
+ (:module options) (conj (:module options))
+ (:modules options) (into (:modules options)))]
+ (module-folders modules)))
+ (dissoc :modules)))))
+
+(comment
+ (parse-options {:modules '[sql-parsing]})
+ (parse-options {:module 'sql-parsing}))
+
(defn find-tests
"Find all tests, in case you wish to run them yourself."
([]
(find-tests {}))
([options]
- (hawk/find-tests-with-options (merge (default-options) options))))
+ (hawk/find-tests-with-options (parse-options options))))
(defn- initialize-all-fixtures []
(let [steps (initialize/all-components)]
@@ -110,10 +133,10 @@
"Find and run tests from the REPL."
[options]
(initialize-all-fixtures)
- (hawk/find-and-run-tests-repl (merge (default-options) options)))
+ (hawk/find-and-run-tests-repl (parse-options options)))
(defn find-and-run-tests-cli
"Entrypoint for `clojure -X:test`."
[options]
(initialize-all-fixtures)
- (hawk/find-and-run-tests-cli (merge (default-options) options)))
+ (hawk/find-and-run-tests-cli (parse-options options)))