Fork me on GitHub
Marco Pas07:01:48

Question about running tests again 🙂

├── src
│   └── cap
└── test
    └── cap
        ├── test_a.clj
        └── test_b.clj
(ns cap.test-a (:require [clojure.test :as t :refer [deftest, is]]))

(deftest test-simple-pass
  (is (= 2 (+ 1 1))))
(ns cap.test-b (:require [clojure.test :as t :refer [deftest, is]]))

(deftest test-simple-fail
  (is (= 3 (+ 1 1))))
I can run a single test file with the recipe like:
#!/usr/bin/env bash
bb -cp "src:test:resources" \
   -e "(require '[clojure.test :as t] '[cap.test-a])
       (let [{:keys [:fail :error]} (t/run-tests 'cap.test-a)]
         (System/exit (+ fail error)))"
But how can i run all tests? Also the tests from test_b.clj


@marco.pasopas you should also require the b namespace and you can use run-all-tests from Clojure.test

Marco Pas08:01:43

@borkdude something like this??

#!/usr/bin/env bash
bb -cp "src:test:resources" \
   -e "(require '[clojure.test :as t] '[cap.test-a] '[cap.test-b])
       (let [{:keys [:fail :error]} (t/run-all-tests)]
         (System/exit (+ fail error)))"
This also runs the tests like
Testing cap.test-a
Testing bencode.core
Testing clj-yaml.core

Marco Pas08:01:07

Would it be more idiomatic to create somekind of test runner namespace or something?


Yes, you can just add the name to run-tests. You can add multiple namespaces there. I updated the book to make this a test runner script instead of a command line expression

👍 3

I’ll update it with multiple namespaces and also with add-classpath

👍 6
Felipe Marques16:01:16

Awesome! I was just going to add tests to the internal CLI of the company that I work for. Btw, do you have any suggestion for easy mocking in Babashaka for tests? I've being using match which gives me a easy way to mach cases for sh calls like this:

(match args
             ["aws" "s3" "cp" "" _] (spit (nth args 4) new-features-config)
             ["aws" "s3" "cp" _ ""] nil
             ["rm" _] (io/delete-file (second args))
             :else (throw (ex-info "unexpected sh call: " args)))))
But as I'm not sure this will work on babashka, I'm running the tests in Clojure


@URUTKFS0H is this core.match?


core.match is now merged to master

❤️ 3

will be included in the next release

❤️ 3
Felipe Marques16:01:50

wow! awesome! thanks!


you can already try it out by downloading a binary from the builds

👍 3

@URUTKFS0H now released as 0.2.8

Felipe Marques23:01:57

Just set up the test runner and the CI using babashka 0.2.8! It worked great including the tests with core.match! Thanks!

🎉 3
Marco Pas08:01:03

Apologies for asking dumb questions 🙂 , still need to get used to the Clojure / BB ecosystem


No problem!


I am looking into including hiccup in babashka for static site generation, but the standard hiccup library doesn't work with GraalVM, since it's based on ... eval 😲

😮 3

Does anyone know of a less "minimal" babashka docker image to use in CI (one that includes e.g. git)


@polymeris There is now a babashka/babashka image and also a babashka-alpine image. The first one is based on ubuntu and the second one on alpine. Both come with curl (for babashka.curl) but nothing more than that. Just derive another image from it.

👍 3
❤️ 3
Jakub Holý (HolyJak)14:01:26

Where can I download a pre-built sql pod binary?


@holyjak do you mean the oracle one?

✔️ 3

Do you mean, for third parties, other than you?

Jakub Holý (HolyJak)14:01:54

No, for me. I supposed that once merged, a binary for each DB and linux/Mac is built and published somewhere. Or do I always need to build pods myself? (for Linux)


But it seems their site is under maintenance 😠


Btw, I now see only 4 jobs, the postgres jobs disappeared?

Jakub Holý (HolyJak)15:01:56

(I want to include it in my aws lambda on Monday and would be happy not to need adding a build stage for it)


I get that. We can distribute it on the pod registry, but I need to know absolutely sure we are not offending any licenses

👍 3
Jakub Holý (HolyJak)15:01:05

Will verify the license

Jakub Holý (HolyJak)16:01:46

I hate Oracle. I will need to try to check this with our legal department. Signals from the internet are ambiguous.


so which license has the helidon driver?

Jakub Holý (HolyJak)16:01:05

Helidon itself has Apache but their driver is literally wrapped ojdbc + reflection json


Maybe post an issue on the Helidon issue tracker to ask how this should be considered?

👍 3

As for the pod-registry, I will not distribute it in case of doubt, don't want the legal department of Oracle on my back

💯 3

So you could maybe build it yourself locally and send it along with your AWS Lambda image

👍 3
Jakub Holý (HolyJak)21:01:32

Thank you very much!


@holyjak One issue, I think the postgres jobs now disappeared


hmm, no sorry. they are there


it was a UI glitch, all good!


Ah, found the issue with hiccup. You have to take care to not map the html macro inside the sci interpreter, but a function, wrapping the macro call, to avoid hiccup to go into "compilation" mode which uses eval 😅

👍 3

Was that a sci of relief I just heard? 🙂

😎 6
Bret Horne21:01:04

Is there a way to interactively develop something with the lanterna pod? This fork doesnt make use of the swing terminal so I was wondering what others have done. (Just remembered that prepl exists so will look further into that)


@bret.horne I read that GraalVM 21 has support now for Swing on linux ( but it's experimental, this is why the lanterna pod doesn't have Swing yet. As for interactive development, there is a socket REPL, pREPL and nREPL in bb

Bret Horne21:01:52

Also, thank you for your work on this btw. I love being able to run clojure in production now for tooling 🙂

❤️ 3
Bret Horne21:01:40

I tried using nrepl first and connecting to that way, in emacs via cider-connect, but im not entirely sure how its supposed to work. The terminal seems to blend in with the repl and I lose all connection to it despite shutting down the terminal.


ah that's tricky, yeah, not sure


fwiw, a lot of the times, I just re-run the scripts I'm developing until it works, since the startup is so fast, the difference with a REPL isn't that big

Bret Horne21:01:45

true. I tried using your clojure-lanterna fork directly and using javac to compile it as im not a lein user but use clj instead.

Bret Horne21:01:33

so Ill continue down that path to run it on the jvm.


yeah, that's also an option

Bret Horne21:01:45

nrepl > /dev/tty seems to work well enough