babashka

seancorfield 2025-07-26T17:11:07.663079Z

Q about exec in a bb task: it looks like (exec 'cognitect.test-runner.api/test) will "exec" (as in clojure -X) that function, and it will do so via Babashka itself (so, testing bb compatibility). Is there a way to invoke a test runner's -main and pass string arguments -- and still have it run inside Babashka?

seancorfield 2025-07-26T17:14:36.750559Z

Context: I want to be able to run LazyTest via Babashka and it doesn't have an "exec" API, only -main, so I need to invoke it with lazytest.main/-main but pass an empty sequence of strings.

borkdude 2025-07-26T17:22:53.559659Z

I’ll answer in a few hours if nobody has answered your question yet

👍🏻 1
lread 2025-07-26T19:52:32.601789Z

So Sean, you want to run your tests not only from bb but in bb (and not run them under the clojure JVM)?

lread 2025-07-26T20:09:55.006569Z

Maybe this will help, from babashka.process bb tasks a https://github.com/babashka/process/blob/35760b076eaad176a61a575b58685c3d3e475d6f/bb.edn#L73-L75 that ends up calling the test runner https://github.com/babashka/process/blob/35760b076eaad176a61a575b58685c3d3e475d6f/bb.edn#L49.

borkdude 2025-07-26T20:28:27.106069Z

@seancorfield You can execute a main function like any other function:

(lazytest.main/-main)
?

borkdude 2025-07-26T20:29:52.926859Z

@lee shouldn't cognitect.test-runner.-main be cognitect.test-runner/-main in that bb.edn? 🤔

🤔 1
borkdude 2025-07-26T20:30:38.153459Z

@seancorfield a shortcut for executing a main function with command line argument in bb tasks is:

{:task foo.bar/-main}
it doesn't require any additional :requires

lread 2025-07-26T20:39:45.209079Z

Yeah. That's weird @borkdude:

$ bb repl
Babashka v1.12.206 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (apply clojure.core.+ [1 2 3])
6
JVM repl:
Clojure 1.12.1
user=> (apply clojure.core.+ [1 2 3])
Syntax error (ClassNotFoundException) compiling at (REPL:1:1).
clojure.core.+
Maybe a sci-ism?

borkdude 2025-07-26T20:40:25.815389Z

@lee weird!

borkdude 2025-07-26T20:41:33.333069Z

I think it may have to do with resolving vars as classes or something, since types likes records and deftypes in SCI are really vars (so far) and people sometimes refer to those by "class" name

borkdude 2025-07-26T20:41:45.182089Z

anyway, better to not rely on that

borkdude 2025-07-26T20:41:53.323269Z

might change in next version

lread 2025-07-26T20:42:12.354059Z

yep. I'll do a quick fix of the typo in bb process.

seancorfield 2025-07-26T21:11:56.873289Z

Oh... gosh, that's simpler than I imagined! Duh!

lread 2025-07-26T21:25:01.930169Z

Hey, you helped us stumble on an interesting weirdness, so it was all worth it! simple_smile

seancorfield 2025-07-26T22:23:55.480599Z

Okay, I now have a branch of deps-new that you can add :build :bb when you create a new app project and the result will have a simpler build.clj and will now have a bb.edn for running tasks including tests. And you can choose a :test-runner of :lazytest (as opposed to Cognitect's test runner) and that also works with Babashka! Now I just need to update the other templates the same way 🙂

🚀 2
borkdude 2025-07-26T22:25:52.173019Z

and on top of that, deps-new itself also works with bb :)

seancorfield 2025-07-27T02:35:56.514429Z

So, calling a main function like this:

{:task foo.bar/-main}
isn't so great when -main calls System/exit since it happens in-process and stops the bb pipeline. Took me a while to figure out why my :depends was running but the actual :task was not -- I was depending on a task that ran -main in-process and exited 😞 So I've gone back to exec and figured out an entry point in LazyTest that works that way.

👍 1
seancorfield 2025-07-27T03:03:22.660429Z

If folks would like to try the :build :bb option in deps-new before I formally cut a v0.10.0 release, I'd appreciate that:

clojure -Ttools install io.github.seancorfield/deps-new '{:git/sha "20e82f8c27b890d03ce71665e07a0f0936a1c3bf"}' :as new

clojure -Tnew app :name myuser/myapp :build :bb

🎉 1