Fork me on GitHub

Confusing behavior of dependent tasks that run Clojure. ๐Ÿงต


 {-install-ws {:doc "Ensure ws is installed for koacha-cljs."
               :task ws/-main}

  test-bb {:doc "Run tests using Babashka"
           :requires ([cognitect.test-runner :as runner])
           :task ((apply runner/-main "-d" "test" *command-line-args*))}

  test-clj {:doc "Run tests using Clojure"
            :task (clojure "-M:test:runner" "clj")}

  test-cljs {:doc "Run tests using ClojureScript"
             :depends [-install-ws]
             :task (clojure "-M:test:runner" "cljs")}

  test {:doc "Run all tests"
        :depends [test-clj test-cljs test-bb]}}}
If I run bb test, it runs all 3 test suites in specified order. But if in test/depends I swap the order, to put test-bb first, then any tasks listed after it do not run. Or if I run bb run --parallel test,then again only test-bb runs, exiting long before the JVM has time to start up for the other tasks.


this is because the test runner calls System/exit probably


Problem is that takes away all the infrastructure around picking test suites to run. But I'm just going to ignore that for now. It's plenty fast enough for this project to just run every BB test every time.


@U90R0EPHA You can do this:

(merge default-opts (babashka.cli/parse-args *commmand-line-args*))


I've made a babashka cli wrapper around test-runner here:


and then call the api function with:

(exec 'cognitect.test-runner.api)


and then options on the command line will be parsed accordingly and passed to the API function


and you can also specify :exec-args as default arguments


So this basically:

{:tasks {test:bb {:extra-paths ["test"]
                  :extra-deps {io.github.cognitect-labs/test-runner
                               {:git/tag "v0.5.1" :git/sha "dfb30dd"}}
                  :task (exec 'cognitect.test-runner.api/test)
                  :exec-args {:dirs ["test"]}
                  :org.babashka/cli {:coerce {:nses [:symbol]
                                              :vars [:symbol]}}}}}


and then:

$ bb test:bb --nses foobar foobaz


Great. Got everything working as expected. Thank you

Annaia Danvers20:11:58

Say I have a big repo, with some subfoloders made up of babashka tasks we've written, each in their own subfolder with their own bb.edn. Would it be possible somehow to make a root bb.edn I can expose as a Git dependency, with each of the subfolders as local dependencies? I've attempted to set this up but I found that :local/root/`:local/deps` didn't work because they wouldn't find the bb.edn files. Is this even a good idea, or would I be better just reorganizing things around a single shared bb.edn?

๐Ÿ‘€ 1

How do people solve this problem with Make?


Is there any special way to call out to a task from a script or from a task function? or should I just shell out to calling bb?


You can do this:

(babashka.tasks/run 'the-task)

๐Ÿ‘ 1

Trying to use pod-babashka-fswatcher, but every file save triggers 4 duplicate :write events. Is this common and/or expected?


There is also another one you can try. I've also seen this but as I haven't written the underlying lib, not sure what is the solution


Got pod-babashka-filewatcher working instead.