Fork me on GitHub
#clojure
<
2021-05-07
>
pinkfrog14:05:24

Hi. Why test-runner has no clojar version, but only gitlib? https://github.com/cognitect-labs/test-runner

ghadi14:05:56

presumably you're using this test runner because you're already using clj tooling

Alex Miller (Clojure team)14:05:13

doesn't need an artifact, so there isn't one

Alex Miller (Clojure team)14:05:56

speaking of test-runner, I was planning to spend a couple hours on it this afternoon triaging tickets and doing some clean up if anyone wants to draw my attention to anything about it

borkdude14:05:43

I'm using it with a lot of pleasure. That it's a git dep will give some people the impression that it's less stable than a mvn artifact, which is maybe ridiculous, but this is how some libraries are now developed: git = experimental, artifact = official. I know you're going to disagree with this, but it's what I perceived in the community.

Alex Miller (Clojure team)15:05:19

I will at least be adding a tag with a version number

Alex Miller (Clojure team)15:05:47

hoping to start changing that perception in the community soon :)

borkdude14:05:27

It's not a problem for me personally. I also use the cljs-test-runner which reflects the same kind of API, which is great in a .cljc project.

dharrigan14:05:52

Whenever I see a git hash, I too think it's less stable (be that justified or not), I graviate towards things that have a version on them.

pinkfrog15:05:17

I wanna specify the -d flag to the clojure test runner and specify that option in deps.edn. Is that possible?

pinkfrog15:05:28

I was thinking :main-opts is something influencing clojure.main directly.

pinkfrog15:05:43

I see, it dispatches on the first toggle being -m, -r or whatever.

vlaaad15:05:47

@alexmiller it would be nice if test-runner was -X -compatible

seancorfield16:05:43

Here’s what we have at work, to be able to use it via -X:

(try
    (let [{:keys [fail error]}
          (runner/test
           (cond-> options
             nsrx ; need to turn strings into regexes:
             (assoc :namespace-regex (into #{} (map re-pattern) nsrx))))]
      (System/exit (if (zero? (+ fail error)) 0 1)))
    (finally
      ;; Only called if `test` raises an exception
      (shutdown-agents)))
^ @alexmiller and we have that in a function like this:
(defn test
  "Invoked via exec-fn (-X) and accepts the same options that Cognitect's
  test-runner uses:

  * :dir -- set of directories containing tests
  * :namespace -- set of namespaces to test
  * :namespace-regex -- set of regex strings to match namespaces
  * :var -- set of fully qualified symbols to run tests on
  * :include -- set of test metadata keywords to filter on
  * :exclude -- set of test metadata keywords to exclude

  Mimics part of test-runner's -main function regarding
  exit code and shutdown."
  [{nsrx :namespace-regex :as options}]

pinkfrog23:05:37

What’s the benefit of -X when -M have all the equivalent functionality?

Alex Miller (Clojure team)23:05:05

Some people prefer one over the other, so now you can choose

seancorfield00:05:51

A concrete benefit : main opts do not merge, exec args do. So you can use different aliases and combine arguments. We leverage that at work. You can't combine main opts like that.

pinkfrog00:05:18

I see. Thanks.

Alex Miller (Clojure team)15:05:47

I'm going to look at that too

Alex Miller (Clojure team)15:05:38

would leave existing support so would be additive