clojure

New to Clojure? Try the #beginners channel. Official docs: https://clojure.org/ Searchable message archives: https://clojurians-log.clojureverse.org/
vncz 2021-05-07T03:27:24.201600Z

I am

2021-05-07T14:33:24.203Z

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

ghadi 2021-05-07T14:40:56.203700Z

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

alexmiller 2021-05-07T14:41:13.204100Z

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

alexmiller 2021-05-07T14:41:56.205Z

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

borkdude 2021-05-07T14:44:43.207Z

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.

borkdude 2021-05-07T14:45:27.207600Z

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.

dharrigan 2021-05-07T14:47:52.208600Z

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.

2021-05-07T15:06:17.209600Z

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

alexmiller 2021-05-07T15:07:05.209800Z

it is

borkdude 2021-05-07T15:07:11.210Z

:main-opts

2021-05-07T15:08:28.210500Z

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

alexmiller 2021-05-07T15:09:19.210600Z

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

alexmiller 2021-05-07T15:09:47.210800Z

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

2021-05-07T15:13:43.211300Z

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

vlaaad 2021-05-07T15:29:47.212100Z

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

alexmiller 2021-05-07T15:35:47.212300Z

I'm going to look at that too

alexmiller 2021-05-07T15:36:20.212500Z

added an issue for it https://github.com/cognitect-labs/test-runner/issues/28

alexmiller 2021-05-07T15:36:38.212900Z

would leave existing support so would be additive

seancorfield 2021-05-07T16:12:43.213Z

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}]

alexmiller 2021-05-07T19:43:21.213200Z

thx

2021-05-07T23:37:37.213500Z

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

alexmiller 2021-05-07T23:43:05.214200Z

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