@borkdude You are really helping me out in understanding BB and also Clojure txs!!
Question about running tests again 🙂
.
├── run-test.sh
├── src
│ └── cap
└── test
└── cap
├── test_a.clj
└── test_b.clj
#test_a.clj
(ns cap.test-a (:require [clojure.test :as t :refer [deftest, is]]))
(deftest test-simple-pass
(is (= 2 (+ 1 1))))
#test_b.clj
(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
@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
Testing clojure.java.browse
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
I’ll update it with multiple namespaces and also with add-classpath
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" "<s3://pipo-prod/features-config-v2.edn>" _] (spit (nth args 4) new-features-config)
["aws" "s3" "cp" _ "<s3://pipo-prod/features-config-v2.edn>"] 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@marques.goncalves.fel is this core.match?
yes
core.match is now merged to master
will be included in the next release
wow! awesome! thanks!
you can already try it out by downloading a binary from the builds
@marques.goncalves.fel now released as 0.2.8
Just set up the test runner and the CI using babashka 0.2.8! It worked great including the tests with core.match! Thanks!
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
😲
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.
Where can I download a pre-built sql pod binary?
@holyjak do you mean the oracle one?
Do you mean, for third parties, other than you?
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)
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
😅
But it seems their site is under maintenance 😠
Btw, I now see only 4 jobs, the postgres jobs disappeared?
(I want to include it in my aws lambda on Monday and would be happy not to need adding a build stage for it)
Was that a sci of relief I just heard? 🙂
I get that. We can distribute it on the pod registry, but I need to know absolutely sure we are not offending any licenses
Will verify the license
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?
Helidon itself has Apache but their driver is literally wrapped ojdbc + reflection json
https://github.com/oracle/helidon/blob/master/integrations/db/ojdbc/pom.xml only mentions Apache
Maybe post an issue on the Helidon issue tracker to ask how this should be considered?
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
So you could maybe build it yourself locally and send it along with your AWS Lambda image
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 (https://medium.com/graalvm/graalvm-21-0-introducing-a-new-way-to-run-java-df894256de28) 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
Also, thank you for your work on this btw. I love being able to run clojure in production now for tooling 🙂
I gotcha.
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
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.
so Ill continue down that path to run it on the jvm.
yeah, that's also an option
nrepl > /dev/tty seems to work well enough
@holyjak For the time being, you can download it from here: https://app.circleci.com/pipelines/github/babashka/babashka-sql-pods/103/workflows/07264b48-367b-43e5-88f4-18784deecab8/jobs/341/artifacts This link will expire in 30 days
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!