This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-22
Channels
- # aleph (18)
- # announcements (4)
- # babashka (72)
- # beginners (63)
- # biff (5)
- # calva (146)
- # cider (5)
- # clj-kondo (18)
- # cljsrn (28)
- # cljtogether (3)
- # clojure (95)
- # clojure-berlin (2)
- # clojure-europe (34)
- # clojure-nl (2)
- # clojure-norway (3)
- # clojure-uk (3)
- # community-development (7)
- # conjure (1)
- # cursive (2)
- # data-science (5)
- # datalevin (9)
- # datomic (17)
- # events (2)
- # figwheel-main (5)
- # fulcro (6)
- # helix (8)
- # hyperfiddle (52)
- # jobs (1)
- # malli (14)
- # off-topic (32)
- # polylith (24)
- # remote-jobs (7)
- # scittle (3)
- # shadow-cljs (13)
- # slack-help (3)
- # spacemacs (3)
- # vim (2)
- # xtdb (6)
What's the latest on automated testing in babashka? I started with Cognitect's test runner as per https://blog.michielborkent.nl/babashka-test-runner.html but wanted to hear what people prefer
First, the blog post is great and got me started very quickly (like, in 3min)
It works great. One thing I don't like is that if there's a failure, the program ends with lots of extra noise
----- Error --------------------------------------------------------------------
Type: clojure.lang.ExceptionInfo
Message: Test failures or errors occurred.
Data: {}
Location: /Users/user/.gitlibs/libs/io.github.cognitect-labs/test-runner/7284cda41fb9edc0f3bc6b6185cfb7138fc8a023/src/cognitect/test_runner/api.clj:30:7
----- Context ------------------------------------------------------------------
26: If neither :nses nor :patterns is supplied, use `:patterns [\".*-test$\"]`."
27: [opts]
28: (let [{:keys [fail error]} (do-test opts)]
29: (when (> (+ fail error) 0)
30: (throw (ex-info "Test failures or errors occurred." {})))))
^--- Test failures or errors occurred.
----- Stack trace --------------------------------------------------------------
cognitect.test-runner.api - /Users/user/.gitlibs/libs/io.github.cognitect-labs/test-runner/7284cda41fb9edc0f3bc6b6185cfb7138fc8a023/src/cognitect/test_runner/api.clj:30:7
exec-1e2ea86e-59cc-440b-86a2-56dbd9dc0f35/exec - <expr>:20:1
exec-1e2ea86e-59cc-440b-86a2-56dbd9dc0f35 - <expr>:4:1
user-4ea00c39-b876-47c8-8d44-bfa33f84922e - <expr>:26:1
For a test runner UX is important - you need to be able to see at a glance what the error is
Of course, cognitect's test runner is only 150 lines of codes or so.... so feel like I almost could copy the code and edit it to my liking
Hm, looking at the code I copied from the blog post, I'm actually calling cognitect.test-runner.api/test
, not cognitect.test-runner/-main
, which should explain the behavior
OK, so if I replace the snippet in the blog post with
{:paths ["src"]
:tasks
{test:bb {:extra-paths ["test"]
:extra-deps {io.github.cognitect-labs/test-runner
{:git/sha "7284cda41fb9edc0f3bc6b6185cfb7138fc8a023"}}
:task cognitect.test-runner/-main}}}
then I get clean test output with no extra stacktrace 🙂Might be worth updating the blogpost in case future readers run into this (maybe cognitect.test-runner/-main
wasn't supported by bb at the time of writing yet)
I think the bb bundled clojure.test could be improved to print the stack trace of the failing test better
Yeah, when I introduce a NullPointerException via (Long/parseLong nil)
in my code, the test runner spits out an unreadable stacktrace starting with :type :sci/error, :line 16, :column 7, :message "null"
...
Full stacktrace
AFAICT, the stacktrace contains references to sci only, but not to locations in my code
@U06F82LES @borkdude Do you use a watcher to run the tests on file changes ?
I usually don't, but you can do it using https://github.com/babashka/pod-babashka-fswatcher
Do you use repl style with bb ?
Could you explain why the example watching project.clj returns (deref (promise)) ?
(deref (promise))
is usually done to block execution. If you wouldn't put it there, the script would terminate immediately
{:pods {org.babashka/fswatcher {:version "0.0.3"}}
:tasks {watch {:requires ([pod.babashka.fswatcher :as fw])
:task (do (fw/watch "project.clj"
(fn [event]
(when (#{:write :write|chmod} (:type event))
(println "hello!"))))
(deref (promise)))}}}
Oh I see.
Very nice embedding spec into bb
@U0516053R I use watchexec --project-origin "$PWD" -w test -w src bb test:bb
I've just tried to use the lanterna pod as per https://github.com/babashka/pod-registry/blob/master/examples/lanterna.clj but I get a file not found exception loading the pod. How should I remedy this?
Specific error text is:
Downloading pod org.babashka/lanterna (0.0.1-SNAPSHOT)
----- Error --------------------------------------------------------------------
Type: java.io.FileNotFoundException
Message:
Location: /home/robin/Videos/./c2.clj:6:1
Just tried with 0.0.1 and it downloaded a 26Mb pod to ~/.babashka but I'm getting a strange IOException 😕
Downloading pod org.babashka/lanterna (0.0.1)
Successfully installed pod org.babashka/lanterna (0.0.1)
----- Error --------------------------------------------------------------------
Type: java.io.IOException
Message: Cannot run program "/home/robin/.babashka/pods/repository/org.babashka/lanterna/0.0.1/linux/x86_64/pod-babashka-lanterna": error=2, No such file or directory
Location: /home/robin/Videos/./c2.clj:6:1
This makes no sense because the pod file is there at that location.can you do :
ldd /home/robin/.babashka/pods/repository/org.babashka/lanterna/0.0.1/linux/x86_64/pod-babashka-lanterna
and show the output?I think it might e a dynamically linked libc problem. I should have gone with static linking but didn't have time to get that in today
linux-vdso.so.1 (0x00007ffc660fa000)
libstdc++.so.6 => not found
libz.so.1 => not found
libpthread.so.0 => /nix/store/c35hf8g5b9vksadym9dbjrd6p2y11m8h-glibc-2.35-224/lib/libpthread.so.0 (0x00007fa230c0b000)
libdl.so.2 => /nix/store/c35hf8g5b9vksadym9dbjrd6p2y11m8h-glibc-2.35-224/lib/libdl.so.2 (0x00007fa230c06000)
librt.so.1 => /nix/store/c35hf8g5b9vksadym9dbjrd6p2y11m8h-glibc-2.35-224/lib/librt.so.1 (0x00007fa230c01000)
libc.so.6 => /nix/store/c35hf8g5b9vksadym9dbjrd6p2y11m8h-glibc-2.35-224/lib/libc.so.6 (0x00007fa22edf7000)
/lib64/ld-linux-x86-64.so.2 => /nix/store/c35hf8g5b9vksadym9dbjrd6p2y11m8h-glibc-2.35-224/lib64/ld-linux-x86-64.so.2 (0x00007fa230c12000)
I can make a static compiled version of this pod tomorrow, but maybe you can get it working by adding libz and libstdc++ in your nix environment... not sure
I'll have a play and let you know but please don't spend more time tonight. Thanks for the lanterna pod update and the pointers to missing libs
Try the binary artifact from this build once it's finished: https://app.circleci.com/pipelines/github/babashka/pod-babashka-lanterna/19/workflows/6684fef3-4678-4e4a-8ec0-84c1dad30750/jobs/42 and copy that over the pod that was downloaded. This should work
I now re-uploaded this binary to the 0.0.1 release. If you do
rm -rf home/robin/.babashka/pods/repository/org.babashka/lanterna
and then try again, it should work. Have a nice evening :)Hi Michiel, thanks for the update. The pod now loads and begins executing but I get an exception in babashka.pods.impl/processor
when I make the first call to (terminal/get-terminal). How can I diagnose a No reader function for tag object
exception myself? You spent quite a bit of your evening last night and I don't want to be a pain
No worries :) Are you able to execute console tetris?
bb -Sdeps '{:deps {io.github.borkdude/console-tetris {:git/sha "2d3bee34ea93c84608c7cc5994ae70480b2df54c"}}}' -m tetris.core
It required a JDK as well as bb but it started without exceptions. I'm using kitty on linux and it draws fine but the key press commands weren't quite working. That's a lanterna issue not bb though.
Feel free to provide a repro of your problem. Perhaps an exception is happening on the pod side
it's the :resize-listener that chokes. Taking that out of the map to get-terminal gets it working.
Wanna play console tetris in bb? (mac + linux only for now)
bb -Sdeps '{:deps {io.github.borkdude/console-tetris {:git/sha "2d3bee34ea93c84608c7cc5994ae70480b2df54c"}}}' -m tetris.core
Btw any reason you're not going for a record here? That already gives you equality for free
It has some methods.
With that said it's more of a learning exercise.
As I'm learning Clojure, I want to first implement it in a way I'm used to from OOP and then make it more idiomatic in order to be able to compare the advantages, reasons etc.