Closed dgr closed 2 years ago
So, (cider.nrepl.inlined-deps.orchard.v0v9v1.orchard.namespace/project-namespaces)
returns clj-tda.api
which has tests.
But :has-tests? true
will filter out this result.
has-tests?
has a straightforward definition that can't be easily fooled:
(defn has-tests?
"Returns a truthy value if the namespace has any vars with `:test` metadata."
[ns]
(seq (filter (comp :test meta val) (ns-interns ns))))
Isn't it possible that clj-tda.api
is not fully loaded?
One easy way to check is:
(cider.nrepl.inlined-deps.orchard.v0v9v1.orchard.namespace/has-tests? (the-ns 'clj-tda.api))
If it returns falsey, it could indicate a code loading issue, which is dependent on one's workflow (one of: repl-driven, using tools.namespace, cider-refresh, etc)
I forced it to load again and here's what I get for various combinations:
clj-tda.api> (cider.nrepl.inlined-deps.orchard.v0v9v1.orchard.query/namespaces {:project? true :has-tests? true})
()
clj-tda.api> (cider.nrepl.inlined-deps.orchard.v0v9v1.orchard.query/namespaces {:has-tests? true})
(#namespace[clj-tda.api-test])
clj-tda.api> (cider.nrepl.inlined-deps.orchard.v0v9v1.orchard.query/namespaces {:project? true})
(#namespace[clj-tda.api] #namespace[clj-tda.tqqq])
It correctly shows "main" namespaces in the project, but not the test namespace.
(in-ns 'cider.nrepl.inlined-deps.orchard.v0v9v1.orchard.namespace)
(cp/classpath)
Maybe the returned value is including "src" but not "test"?
Here's the output:
clj-tda.api> (in-ns 'cider.nrepl.inlined-deps.orchard.v0v9v1.orchard.namespace)
(cp/classpath)
#namespace[cider.nrepl.inlined-deps.orchard.v0v9v1.orchard.namespace](#object[java.net.URL 0x2a251ffe "file:/Users/dave/clojure/clj-tda/src/"]
#object[java.net.URL 0xbcbb325 "file:/Users/dave/clojure/clj-tda/resources/"]
#object[java.net.URL 0x75a17782 "file:/Users/dave/.m2/repository/better-cond/better-cond/2.1.4/better-cond-2.1.4.jar"]
#object[java.net.URL 0x2a551795 "file:/Users/dave/.m2/repository/camel-snake-kebab/camel-snake-kebab/0.4.2/camel-snake-kebab-0.4.2.jar"]
#object[java.net.URL 0x36ee42df "file:/Users/dave/.m2/repository/cider/cider-nrepl/0.28.1/cider-nrepl-0.28.1.jar"]
#object[java.net.URL 0x60ea8dbc "file:/Users/dave/.m2/repository/clj-http/clj-http/3.12.3/clj-http-3.12.3.jar"]
#object[java.net.URL 0x1e89fb44 "file:/Users/dave/.m2/repository/cljc/java-time/cljc.java-time/0.1.18/cljc.java-time-0.1.18.jar"]
#object[java.net.URL 0x1c62aebf "file:/Users/dave/.m2/repository/etaoin/etaoin/0.4.6/etaoin-0.4.6.jar"]
#object[java.net.URL 0x58deef56 "file:/Users/dave/.m2/repository/failjure/failjure/2.2.0/failjure-2.2.0.jar"]
#object[java.net.URL 0x6c6d0e9c "file:/Users/dave/.m2/repository/funcool/promesa/6.0.2/promesa-6.0.2.jar"]
#object[java.net.URL 0x3d6f8b8e "file:/Users/dave/.m2/repository/metosin/jsonista/0.3.5/jsonista-0.3.5.jar"]
#object[java.net.URL 0x3471cdca "file:/Users/dave/.m2/repository/nrepl/nrepl/0.9.0/nrepl-0.9.0.jar"]
#object[java.net.URL 0x1b7a304d "file:/Users/dave/.m2/repository/org/bovinegenius/exploding-fish/0.3.6/exploding-fish-0.3.6.jar"]
#object[java.net.URL 0x1f67d450 "file:/Users/dave/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar"]
#object[java.net.URL 0x5e150fc9 "file:/Users/dave/.m2/repository/refactor-nrepl/refactor-nrepl/3.2.0/refactor-nrepl-3.2.0.jar"]
#object[java.net.URL 0x64b0965c "file:/Users/dave/.m2/repository/commons-codec/commons-codec/1.15/commons-codec-1.15.jar"]
#object[java.net.URL 0x2e023adf "file:/Users/dave/.m2/repository/commons-io/commons-io/2.8.0/commons-io-2.8.0.jar"]
#object[java.net.URL 0xf66ae1b "file:/Users/dave/.m2/repository/org/apache/httpcomponents/httpasyncclient/4.1.4/httpasyncclient-4.1.4.jar"]
#object[java.net.URL 0x797b9379 "file:/Users/dave/.m2/repository/org/apache/httpcomponents/httpclient/4.5.13/httpclient-4.5.13.jar"]
#object[java.net.URL 0x1999f87c "file:/Users/dave/.m2/repository/org/apache/httpcomponents/httpclient-cache/4.5.13/httpclient-cache-4.5.13.jar"]
#object[java.net.URL 0x2672ed52 "file:/Users/dave/.m2/repository/org/apache/httpcomponents/httpcore/4.4.14/httpcore-4.4.14.jar"]
#object[java.net.URL 0x1cde89f1 "file:/Users/dave/.m2/repository/org/apache/httpcomponents/httpmime/4.5.13/httpmime-4.5.13.jar"]
#object[java.net.URL 0x391b2148 "file:/Users/dave/.m2/repository/potemkin/potemkin/0.4.5/potemkin-0.4.5.jar"]
#object[java.net.URL 0x6f97740f "file:/Users/dave/.m2/repository/slingshot/slingshot/0.12.2/slingshot-0.12.2.jar"]
#object[java.net.URL 0x5e3e1cd2 "file:/Users/dave/.m2/repository/cljs/java-time/cljs.java-time/0.1.19/cljs.java-time-0.1.19.jar"]
#object[java.net.URL 0x36c797e5 "file:/Users/dave/.m2/repository/cheshire/cheshire/5.9.0/cheshire-5.9.0.jar"]
#object[java.net.URL 0x56b6f114 "file:/Users/dave/.m2/repository/org/clojure/data.codec/0.1.0/data.codec-0.1.0.jar"]
#object[java.net.URL 0x255d0c1 "file:/Users/dave/.m2/repository/org/clojure/tools.cli/1.0.194/tools.cli-1.0.194.jar"]
#object[java.net.URL 0x2ca384d5 "file:/Users/dave/.m2/repository/org/clojure/tools.logging/0.3.1/tools.logging-0.3.1.jar"]
#object[java.net.URL 0x2651461b "file:/Users/dave/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.13.0/jackson-core-2.13.0.jar"]
#object[java.net.URL 0x470e3d94 "file:/Users/dave/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.13.0/jackson-databind-2.13.0.jar"]
#object[java.net.URL 0x6b712e6c "file:/Users/dave/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.13.0/jackson-datatype-jsr310-2.13.0.jar"]
#object[java.net.URL 0x5bc48afb "file:/Users/dave/.m2/repository/org/clojure/core.specs.alpha/0.2.56/core.specs.alpha-0.2.56.jar"]
#object[java.net.URL 0x77897e06 "file:/Users/dave/.m2/repository/org/clojure/spec.alpha/0.2.194/spec.alpha-0.2.194.jar"]
#object[java.net.URL 0x41dd0ffe "file:/Users/dave/.m2/repository/commons-logging/commons-logging/1.2/commons-logging-1.2.jar"]
#object[java.net.URL 0x233d5be7 "file:/Users/dave/.m2/repository/org/apache/httpcomponents/httpcore-nio/4.4.10/httpcore-nio-4.4.10.jar"]
#object[java.net.URL 0x5cd19e29 "file:/Users/dave/.m2/repository/clj-tuple/clj-tuple/0.2.2/clj-tuple-0.2.2.jar"]
#object[java.net.URL 0x6094a2fb "file:/Users/dave/.m2/repository/riddley/riddley/0.1.12/riddley-0.1.12.jar"]
#object[java.net.URL 0x491ff3e8 "file:/Users/dave/.m2/repository/henryw374/js-joda/3.2.0-0/js-joda-3.2.0-0.jar"]
#object[java.net.URL 0x347b4f "file:/Users/dave/.m2/repository/net/cgrand/macrovich/0.2.0/macrovich-0.2.0.jar"]
#object[java.net.URL 0x50c49db6 "file:/Users/dave/.m2/repository/com/fasterxml/jackson/dataformat/jackson-dataformat-cbor/2.9.9/jackson-dataformat-cbor-2.9.9.jar"]
#object[java.net.URL 0x15826e2f "file:/Users/dave/.m2/repository/com/fasterxml/jackson/dataformat/jackson-dataformat-smile/2.9.9/jackson-dataformat-smile-2.9.9.jar"]
#object[java.net.URL 0x23b44fc4 "file:/Users/dave/.m2/repository/tigris/tigris/0.1.1/tigris-0.1.1.jar"]
#object[java.net.URL 0x79a6fe "file:/Users/dave/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.13.0/jackson-annotations-2.13.0.jar"])
So indeed it includes "file:/Users/dave/clojure/clj-tda/src/"
but not "file:/Users/dave/clojure/clj-tda/test/"
.
I'd recommend checking which deps.edn aliases are you passing to CIDER. Typically :test should be somewhere in there e.g.:
...
(cider-clojure-cli-global-options . "-A:dev:test")
Hm, where am I looking for that, exactly?
Here's the deps.edn, if it matters.
{:paths ["src" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.10.3"}
camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.2"}
metosin/jsonista {:mvn/version "0.3.5"}
etaoin/etaoin {:mvn/version "0.4.6"}
clj-http/clj-http {:mvn/version "3.12.3"}
cljc.java-time/cljc.java-time {:mvn/version "0.1.18"}
org.bovinegenius/exploding-fish {:mvn/version "0.3.6"}
funcool/promesa {:mvn/version "6.0.2"}
failjure/failjure {:mvn/version "2.2.0"}
better-cond/better-cond {:mvn/version "2.1.4"}}
:aliases
{:test
{:extra-paths ["test"]
:extra-deps {org.clojure/test.check {:mvn/version "1.1.1"}
io.github.cognitect-labs/test-runner
{:git/tag "v0.5.0" :git/sha "48c3c67"}}}
:build {:deps {io.github.seancorfield/build-clj
{:git/tag "v0.6.6" :git/sha "171d5f1"}}
:ns-default build}}}
Per https://docs.cider.mx/cider/basics/up_and_running.html either you've opted to Launch an nREPL Server From Emacs
which would need cider-clojure-cli-global-options
to be tweaked, or you'd be opting to Connect to a Running nREPL Server
which needs you to run an nREPL server from the terminal with the :test
alias being specified by hand in that CLI invocation.
Ah, I haven't done that. OK, let me try it and get back to you. For the past many years, I've been using CIDER with Leiningen projects and it Just Worked. This time, I decided to move over and try tools.deps and I'm still learning the differences.
Yep, that was it. Sorry to have troubled you. I was so used to CIDER just working out of the box with very little other configuration with Leiningen-based projects.
Alright!
No issue, will hammock if we can provide some alias inference for deps.edn users.
Ah, I haven't done that. OK, let me try it and get back to you. For the past many years, I've been using CIDER with Leiningen projects and it Just Worked. This time, I decided to move over and try tools.deps and I'm still learning the differences.
I know there's a massive exodus to tools.deps
, but I really don't get it. It seemed that people are trading a lot of convenience for the benefit of not using a 3rd party tool.
Probably we should add some bigger warnings about the necessary setup in the tools.deps
section of the docs.
Yes, that's one reason why I wanted to try it. I've just used Leiningen habitually since I really started with Clojure in earnest (and gave up trying to use Clojure once before that because Leiningen didn't exist at that point). tools.deps
seems to have a lot of flexibility and tune-ability, but it's definitely not "batteries included" and there seem to be many ways to do the same thing, which probably hampers something like CIDER "just working."
On this particular issue, I think CIDER could do two things that would help:
tools.deps
. @vemv pointed me at the manual section that mentions cider-clojure-cli-aliases
, but it's obscure and not well highlighted. In particular, it doesn't mention anything about tests. Ideally, there would be two sections (maybe more, I guess). One for "If using Leiningen..." and "If using tools.deps
..." and then outline all the things that people probably want to do but haven't thought of.deps.edn
and looking for a test
or tests
alias and automatically injecting that if cider-clojure-cli-aliases
is not set. If cider-clojure-cli-aliases
is set, then assume the user knows what she wants and give it to her. IMO, wanting tests injected and naming the alias test
or tests
will be the common use case. If the project creation utilities for tools.deps
can settle on a "standard" default name, you would hit 99% of the Clojure projects out there.In any case, thanks for all the work you folks put into CIDER/orchard/etc. It's a really great ecosystem. I've tried to contribute something back in the past by editing the manual and will continue to do so.
Expected behavior
Running tests for project (C-c C-t C-p) or namespace (C-c C-t C-n) should result in project or namespace level tests being run.
Actual behavior
This does not happen. Running tests for project or namespace results in a message saying that tests were not found.
Steps to reproduce the problem
Create a new project. Execute tests per the keystrokes above.
Environment & Version information
Orchard version is whatever comes with cider-20220121.1047 installed from Elpa. On Clojurian's Slack, @vemv asked me to execute some things in the REPL. Here is that output.
I have two namespaces in my project,
clj-tda.api
andclj-tda.tqqq
. The first,clj-tda.api
, has tests.Clojure version
1.10.3
Java version
Azul Zulu 17.0.1 installed via MacOS Homebrew.
Operating system
MacOS 12.1