Fork me on GitHub
#babashka
<
2022-12-11
>
Alex Alemi01:12:51

Ran into some trouble today trying to pass a negative double as an argument to babashka cli, it was being parsed as a flag. Am I missing something?

borkdude07:12:25

Seems like an edge case, feel free to report

borkdude08:12:25

A workaround for now is to invoke the CLI with: foo.clj :opt1 bar :opt2 baz, then it will not try to read flags with a - prefix

Alex Alemi22:12:01

Thanks! My current workaround was to have separate tasks for deposit and withdrawal so the sign was declared in the task which worked for my case

šŸ‘ 1
Martynas Maciulevičius11:12:18

Is this the way to run tests via babashka? deps.edn:

:test-runner/babashka
  {:extra-deps {io.github.cognitect-labs/test-runner {:git/tag "v0.5.0"
                                                      :git/sha "b3fd0d2"}
                ;; Specifies custom test runner that runs babashka tests without
                ;; the patching tools.namespace ns: 55:00 
                org.clojure/tools.namespace
                {:git/url ""
                 :git/sha "3625153ee66dfcec2ba600851b5b2cbdab8fae6c"}}
   :main-opts ["-m" "cognitect.test-runner"]}
bb.edn:
;; bb test-bb
         test-bb {:doc "Run tests via bb"
                  :task (do (println "Running tests via Babashka")
                            (clojure "-M:project/dev:project/test:test-runner/babashka"))}
It gives me the same execution time as if I'd be running tests in JVM clojure (I used time command to "measure")

borkdude11:12:21

Do you mean run tests "in" babashka? I.e. test code written for babashka?

lispyclouds13:12:29

@U028ART884X the way your code is written here would launch a JVM to load the deps from deps.edn and run the tests in that JVM. All bb is doing here is to fork that process, not execute any of the tests "in" bb. Hence the time taken is the same.

Martynas Maciulevičius13:12:55

Ah right šŸ˜„ I'll try to fix it, thanks

Martynas Maciulevičius12:12:42

How does one include -M options into the babashka test runner that's described here? https://blog.michielborkent.nl/babashka-test-runner.html I'd like to include some resource dirs from a profile from deps.edn :thinking_face:

lispyclouds12:12:29

bb would only read bb.edn. you can pass the resources path in :`extra-paths` maybe? in the bb task

borkdude12:12:44

yes, that's how to do it :)

Martynas Maciulevičius12:12:56

I know I can code it into the bb.edn file. But for instance I could have some new dependencies, JVM args, maybe env args, configs. Edit: ofc JVM args could probably be irrelevant

lispyclouds13:12:11

what would be an example of things you'd like to pass?

Martynas Maciulevičius13:12:47

I only don't want to duplicate config in two places. So for instance I'd like to have a dependency that's saved in deps.edn profile that I only add to tests.

borkdude13:12:59

@U028ART884X You can do it programmaticaly using babashka.deps/add-deps

Martynas Maciulevičius13:12:42

For instance I could have this dependency while running tests but not in main deps config:

pjstadig/humane-test-output {:mvn/version "0.11.0"}

borkdude13:12:50

you can slurp / edn-parse the deps.edn yourself and provide a :aliases argument

borkdude13:12:22

For extra deps in tests you can also use :extra-deps in bb.edn

Martynas Maciulevičius13:12:47

What do you mean by > you can slurp / edn-parse the deps.edn yourself and provide a :aliases argument Can I do this?

:aliases ["test"]

Martynas Maciulevičius13:12:48

:aliases in bb.edn don't get picked up. So what you suggest is to generate bb.edn's babashka test config? It seems to be not that useful for what it would provide.

borkdude13:12:01

no, what I mean is programmatically add to the classpath instead of using bb.edn

Martynas Maciulevičius13:12:35

I'm confused. Should I treat babashka as a standalone executable or can I add a JAR to its runtime and run it? Edit: Well I used malli from babashka just fine, so it's somehow capable to side-load things. Edit2: probably we'd need to have some kind of clojure -M command for babashka so that it could load the deps.edn automatically without a separate script that would produce the bb.edn options for it (classpath).

lispyclouds13:12:40

so what we could essentially do as bb doesn't read deps.edn implicitly: ā€¢ use the babashka.deps/add-deps to add the deps to its class path ā€¢ to get these deps, you need to load the deps edn programatically and call the add-deps with the relevant deps ā€¢ then execute the tests this is my understanding, maybe borkdude has better ideas šŸ˜„

borkdude13:12:19

or just duplicate the config

Martynas Maciulevičius13:12:55

Or write a babashka script that would duplicate the config for you :thinking_face:

Martynas Maciulevičius13:12:20

But yes, the easiest thing to do is to duplicate the config because that would mean that you verify each dependency in it. But the downside is that now you have two configs from which both are equally important which is not ideal. And then they have to mean the same thing even though the syntax is different.

borkdude13:12:25

This should give you what you need, if you don't want to duplicate. There are no other options at the moment: https://book.babashka.org/#_add_deps

šŸ‘ 1
nonrecursive15:12:58

hey folks, Iā€™ve been putting together a babashka tutorial and was hoping to get feedback: https://github.com/braveclojure/babooka. Are there any typos or mistakes of that nature? Is there something youā€™d like to see covered? Is anything unclear? My goal is to get more people using babashka :) (p.s. please donā€™t share it elsewhere though šŸ™‚ I donā€™t want to share it broadly until I put it on the brave clojure site)

ā¤ļø 3
šŸ‘€ 1
nonrecursive15:12:34

it looks like *command-line-args* is getting bolded and not showing asterisks šŸ˜•

borkdude16:12:56

@U0AQ1R7FG I believe in markdown it doesn't have this problem. Is your original in org mode or asciidoc?

borkdude16:12:41

you could try \*command-line-args\*

lread17:12:39

For adoc inline code snippets, if that's what you are doing, I have used:

`+*command-line-args*+
`

nonrecursive13:12:53

Cool, thanks! The original is the org mode one