This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-07-14
Channels
- # announcements (4)
- # babashka (32)
- # beginners (24)
- # calva (3)
- # cider (37)
- # clj-commons (8)
- # clj-kondo (6)
- # clojure (51)
- # clojure-denver (7)
- # clojure-europe (48)
- # clojure-nl (1)
- # clojure-norway (2)
- # clojure-uk (2)
- # clojurescript (12)
- # core-async (10)
- # cursive (9)
- # datomic (42)
- # hyperfiddle (25)
- # jobs (4)
- # juxt (2)
- # lsp (10)
- # malli (11)
- # off-topic (32)
- # polylith (6)
- # practicalli (1)
- # react (2)
- # releases (1)
- # remote-jobs (2)
- # spacemacs (4)
- # xtdb (4)
I believe I must be doing something wrong. so -- I’ve got a bunch of tests, laid out like this
.
├── bb.edn
├── test
│ ├── basic
│ │ └── basic_test.clj
│ ├── data-kafka
│ │ └── data_kafka_test.clj
│ ├── sql-send
│ │ └── sql_send_test.clj
each of the test/xyz
folders contains some extra files.
now to run them via bb run tests
, I’ve got a bb.edn
of
{:tasks
{tests {:extra-paths ["test/basic" "test/data-kafka" "test/sql-send" "test/"]
:extra-deps {io.github.cognitect-labs/test-runner {:git/tag "v0.5.1" :git/sha "dfb30dd"}
listora/again {:mvn/version "1.0.0"}}
:task (exec 'cognitect.test-runner.api/test)
:exec-args {:dirs ["test"]}
:org.babashka/cli {:coerce {:nses [:symbol]
:vars [:symbol]}}}}}
and what bugs me is that I seemingly need to list all sub-directories in :extra-paths
. but I don’t know where to start cleaning this up. 🧵please correct me if I’m wrong here: I provide those paths to extra-paths to > add paths to the classpath and bb will load everything that in the classpath; and the test runner will walk all vars, checking for tests.
oh. I could put all the .clj files into test/
and still reference the dirs like I did before and it’ll probably just work. I have to try this.
you could just add "test"
to the extra-paths and adjust your namespace names accordingly
so, leave the files where they are? in the subdirs?
I think I’m missing some basic thing wrt file names and namespaces.
the entries in paths should generally be the classpath roots from which namespaces can be resolved - I guess I would see the trade-off as "if I need to keep those test sets separate because I'm going to refer to them separately, then I need the separate dirs; if I'm always going to use all the directories together, then they could presumably be one directory" (and maybe tweak the ns names like borkdude said)
what namespace should
test/basic/basic_test.clj
have then?If you add test
to the extra paths and you have a file like:
test/foo/bar.clj
the namespace name has to be (ns foo.bar)
so in the case of:
test/basic/basic_test.clj
the ns name should be:
(ns basic.basic-test)
thanks! that helps a lot
basic seems to work fine, but kondo keeps complaining about
(ns data-kafka.data-kafka-test)
for
test/data-kafka/data_kafka_test.clj
> Example trigger: a folder/file containing dashes instead of underscores, example: example-namespace/foo.clj
containing a namespace (ns example-namespace.foo)
.
yep! thanks again
I there, I had the following in a bb.edn
(shell "bb" uberjar (str uber-file) "-f" script-path "-m" (str main-sym))
This now v1.3.181
throws
----- Error --------------------------------------------------------------------
Type: java.lang.Exception
Message: File does not exist: -f
Did I miss a breaking change?I don't see -f
anymore to uberjar
well it probably has never been there but now it actually is not only ignored but bb
fails properly (maybe)
Oh ok, I am going to open an issue on GitHub then
@U04V15CAJ Sorry, I might not remember this properly but what was the original purpose of -f
? I might want to remove it cause I see all the namespaces in the produced jar
cause it is not in the eval-opts
- so I was now thinking that it is correct that it fails
there was a change around -f recently which had to do with running scripts with an adjacent bb.edn file.
I honestly don't see it used [here](https://github.com/babashka/babashka/blob/94c5141a3eda7e07ed2efa40c11efe3d4c13a297/src/babashka/main.clj#L1088-L1101) so probably this behavior is breaking but correct and my script was wrong