Fork me on GitHub
#tools-deps
<
2022-07-25
>
pinkfrog10:07:03

{:exclusions [foo/lib]} excludes foo/lib, what’s the counterpart that ensures a specific version of foo/lib is used?

p-himik10:07:58

Just add it to your :deps or :extra-deps with that version.

pinkfrog10:07:54

It is a lib. So other libs conflicts with it. I cannot control the :deps of the project.

p-himik10:07:36

I don't understand what you mean. Can you give a concrete example? With a description of what you can and cannot control.

delaguardo10:07:18

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

p-himik10:07:46

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.

pinkfrog11:07:12

Right. But My goals is the contrary, to forcefully obey

{:deps {lib/b {:mvn/version "0.0.3"}}}

p-himik14:07:03

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.

Chase14:07:43

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.

p-himik14:07:44

Maybe it gathered all your tests twice? Not sure why exactly - maybe some bug in the runner, maybe something's wrong in your setup.

Chase14:07:25

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

Chase14:07:06

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)))))

Chase14:07:13

did I do something silly there?

Chase14:07:53

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.

p-himik14:07:36

And no "test" in the :paths in deps.edn?

p-himik14:07:10

I just did the same thing (but replaced 0 with 3 and add with +), and my tests ran only once.

Chase14:07:25

I didn't even catch that it wasn't catching the failing test. That is a problem. Hmmm

Chase14:07:02

And no, I have :paths ["src" "resources"] in the deps.edn

Chase14:07:16

My repl connected editor catches that failing test.

Chase15:07:23

Is my deftest form actually correct? I'm coming back to clojure after a little break so was just going off memory there.

p-himik15:07:53

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.

Chase15:07:26

Will do, give me 1 minute. Thanks!

p-himik15:07:22

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).

Chase15:07:23

accidentily left in a dep for criterium fyi, I just push a commit removing that.

Chase15:07:02

oh my goodness, I left that file in there huh. I told you I was doing something silly! Sorry for wasting your time.

p-himik15:07:17

No problem. :)

Chase15:07:45

oh wait, but it's still not catching the failed test (even though it now only runs once of course)

Chase15:07:11

Nope, still being silly, I had changed the test to be successful. Hahaha!

👍 1
Chase15:07:17

I need more coffee

Chase15:07:28

Thanks again for the assistance

🙂 1