tools-build 2023-08-05

I am trying to create a build function for running tests:

(defn create-opts [cli-opts aliases]
  (let [lib 'org.clojars.roklenarcic/paginator
        target (:target cli-opts "target")
        scm (cond (:tag cli-opts) {:tag (:tag cli-opts)}
                  version {:tag (str "v" version)})]
    (merge {:basis (if aliases (b/create-basis {:aliases aliases}) (b/create-basis))
            :lib lib :version version :class-dir (str target "/classes") :target target
            :src-dirs ["src"] :resource-dirs ["resources"] :scm scm
            :jar-file (format "%s/%s-%s.jar" target (name lib) version)}
           cli-opts)))

(defn run-tests [opts]
  (let [cmd (b/java-command (assoc (create-opts opts ["test"])
                              :main 'clojure.main
                              :main-args ["-m" "cognitect.test-runner"]))
        {:keys [exit]} (b/process cmd)]
    (when-not (zero? exit)
      (throw (ex-info "Tests failed" {})))
    opts))
The problem is that it doesn’t seem to pick up my “test” alias deps when running this task…
Could not locate cognitect/test_runner__init.class, cognitect/test_runner.clj or cognitect/test_runner.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.

is it that the test alias needs to be a keyword?

yes you are right

thank you

👍 1