This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-25
Channels
- # announcements (9)
- # babashka (38)
- # beginners (41)
- # biff (1)
- # clojure (19)
- # clojure-europe (7)
- # clojure-uk (2)
- # clojurescript (3)
- # code-reviews (30)
- # conjure (4)
- # cursive (8)
- # datomic (32)
- # docker (2)
- # emacs (7)
- # etaoin (2)
- # fulcro (37)
- # graphql (2)
- # jobs (1)
- # jobs-discuss (8)
- # leiningen (10)
- # lsp (36)
- # meander (4)
- # missionary (4)
- # nbb (12)
- # off-topic (1)
- # other-languages (10)
- # pathom (11)
- # re-frame (5)
- # reitit (4)
- # remote-jobs (3)
- # shadow-cljs (13)
- # sql (1)
- # tools-build (4)
- # tools-deps (31)
- # xtdb (2)
{:exclusions [foo/lib]}
excludes foo/lib, what’s the counterpart that ensures a specific version of foo/lib is used?
It is a lib. So other libs conflicts with it. I cannot control the :deps of the project.
I don't understand what you mean. Can you give a concrete example? With a description of what you can and cannot control.
you control your deps.edn this should be a place where you declare some specific version of some library. and it will take precedence even if another lib in your dependency tree excludes it
To make make the above more concrete with an example.
Your deps.edn
:
{:deps {lib/a {:mvn/version "1.0.0"}
lib/b {:mvn/version "0.0.2"}}}
The lib/a
's deps.edn
:
{:deps {lib/b {:mvn/version "0.0.3"}}}
Your project will end up having lib/b
version 0.0.2
even though lib/a
depends on a newer version.Right. But My goals is the contrary, to forcefully obey
{:deps {lib/b {:mvn/version "0.0.3"}}}
I believe the only reasonable way to do it is to just specify that version manually. But you can have a test that makes sure that it's the right version at all times.
I set up a test
alias according to the cognitect test runner
repo and when invoking it with clj -X:test
it runs all tests twice. When I use my editor's built in test functionality it only runs them once as expected. nbd but just curious why that might be happening.
Maybe it gathered all your tests twice? Not sure why exactly - maybe some bug in the runner, maybe something's wrong in your setup.
:test {:extra-paths ["test"]
:extra-deps {io.github.cognitect-labs/test-runner
{:git/url ""
:sha "9e35c979860c75555adaff7600070c60004a0f44"}}
:main-opts ["-m" "cognitect.test-runner"]
:exec-fn cognitect.test-runner.api/test}}}
that's in my deps.edn
and my minimal tester is just:
ns practice.scratch-test
(:require
[clojure.test :refer :all]
[practice.scratch :refer :all]))
(deftest a-test
(testing "add"
(is (= 0 (add 1 2)))))
the results:
λ ~/projects/clojure/practice : clj -X:test
Running tests in #{"test"}
Testing practice.scratch-test
Testing practice.scratch-test
Ran 2 tests containing 2 assertions.
0 failures, 0 errors.
I just did the same thing (but replaced 0
with 3
and add
with +
), and my tests ran only once.
Is my deftest
form actually correct? I'm coming back to clojure after a little break so was just going off memory there.
Your deftest
is correct.
But I don't know why it tests the same thing twice and doesn't catch the error. If you can share a minimal reproducible example as a Git repo, I'd take a look.
You have test/scratch_test.clj
with (ns practice.scratch-test ...)
.
And you have test/practice/scratch_test.clj
with the same NS.
Remove the first one, change the second one (it won't fail otherwise).
oh my goodness, I left that file in there huh. I told you I was doing something silly! Sorry for wasting your time.