Fork me on GitHub
#babashka
<
2024-02-20
>
pedrorgirardi10:02:41

I’m using tools-deps-native to slurp a deps.edn (`slurp-deps`), and then create a basis for a project. The deps-maps is read “correctly”, but basis is always from the current working directory. I’m not sure if this is a bug, or the expected behavior.

pedrorgirardi10:02:20

I start Babashka as a subprocess of my editor; cwd is where my Babashka project is, but I’m trying to read the classpath, using tools-deps-native, from a different directory (based on deps-map).

borkdude10:02:46

What it the behavior with normal tools.deps?

pedrorgirardi10:02:45

Hm..good question. I haven’t tried because I’m using from Babashka.

pedrorgirardi10:02:07

Does it sound reasonable to you what I’m trying to do? Starting Babashka from its ‘project directory’, and then using tools-deps-native to analyze other projects (in different directories).

borkdude10:02:40

tools.bbuild is a wrapper around the tools-deps-native pod

pedrorgirardi10:02:09

Awesome! I will have a look.

pedrorgirardi10:02:51

I’m doing a strange experiment 😅 Using Babashka to interface with clj-kondo to analyze a project, persist the analyzes data as JSON files, and query analysis data (JSON files) with DuckDB. It’s an experimental branch of my SublimeText plugin.

👍 1
borkdude10:02:37

What people around here are using bb on an intel Mac? Someone reported that the newer versions stopped working on older macOS versions. This is probably because I'm using a too new xcode version (15). I downgraded xcode in a branch to 12.something and the binary started working again for him. But I want to know if that binary still works for people here. Please test this binary if you're into this target audience: https://output.circle-artifacts.com/output/job/bb481147-ec43-4f0c-896f-9a5008679897/artifacts/0/release/babashka-1.3.189-SNAPSHOT-macos-amd64.tar.gz

borkdude10:02:36

Please respond in this thread 🧵

Wanishing10:02:38

I'm using 2.6 GHz 6-Core Intel Core i7 and it worked on my machine

borkdude10:02:54

and which macos version?

borkdude10:02:02

(thanks for testing btw!)

🙏 1
Wanishing10:02:42

MacBook Pro 2019, Sonoma 14.2.1 (23C71)

borkdude10:02:37

The macos version is something like 10.12 or 12.7.2, etc. You can find this in "About my Mac"

borkdude10:02:46

ah right, 14.2.1

borkdude10:02:52

sounds good

Wanishing10:02:58

Yeah I looked there

jaydeesimon02:02:31

Worked for me as well

👍 1
ambrosebs00:02:51

Works on Sonoma 14.3 on a 2020 Intel MBP.

👍 1
Hanisha Jain15:02:53

Hello there I need help with Babashka testing So i have a script "test-notify-tag.clj" and this script is in test directory which is inside bb directory bb directory have bb.edn file as usual I tried multiple research and help of ChatGPT to run test using bb test command but seem to fail. Edited edn so many times that now i feel lost Can someone help me with bb test ? or link or reference ? To set up?

Samuel Ludwig15:02:02

can you post any output/stacktraces of what happens when it "seems to fail", along with the command that you run to test it?

borkdude15:02:08

Can you share your project maybe?

Hanisha Jain15:02:38

alright. So i found one blog: https://blog.michielborkent.nl/babashka-test-runner.html Before this blog: i run command bb test Error Couldn't find test file Just now, after reading this blog. i updated my edn file to this: and it shows 0 test ran

{:paths ["bb" "."]

 :deps {}
 :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]}}}}}

Hanisha Jain15:02:05

Terminal output: Running tests in #{"test"} Testing exec-34ac8f70-b8ff-4aa4-bfa1-c475a662c238 Ran 0 tests containing 0 assertions. 0 failures, 0 errors.

borkdude15:02:35

Where is your test file relative to your working directory?

Hanisha Jain15:02:09

so test file name is test-notify-tag.clj And this file is inside test directory bb/test/test-notify-tag.clj edn file is inside bb

borkdude15:02:14

If you add :paths ["test"] this isn't adding bb/test to the classpath, but only test

borkdude15:02:35

you are assuming a nesting that isn't there

Hanisha Jain15:02:18

so rectified edn file would be:

{:paths ["bb" "."]

 :deps {}
 :tasks
 {test:bb {:extra-paths ["bb/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]}}}}}

borkdude15:02:42

I guess so, but it's weird to have an overlapping classpath

borkdude15:02:55

you already have bb on your classpath and then you add bb/test as well

borkdude15:02:10

perhaps it's better to create a separate bb-test directory next to bb

borkdude15:02:29

or just move the tests one directory up inside bb

Hanisha Jain15:02:55

amm cant we segregate all test files somehow inside bb?

borkdude15:02:33

of course you can, but the classpath works the same way as in normal Clojure. If you don't know about that, perhaps ask around in #C053AK3F9 to see how it works

borkdude15:02:45

adding bb/test will work btw, it's just not that common to do it that way

Hanisha Jain15:02:23

i got you! Not so cleaner. Mentioning bb and also adding a folder which exist inside bb

Hanisha Jain15:02:18

amm aint sure why it still says 0 test ran.

borkdude15:02:52

Are you running bb test:bb ?

borkdude15:02:40

It would be better if you could share your project on Github or at least a reproduction of your problem, else it's really hard to make sense of it

Hanisha Jain15:02:07

i can understand terminal logs: PS H:\Iroh\Devops\bb> bb test:bb Running tests in #{"test"} Testing exec-f3fecdbd-ec08-42cd-bf1e-0a92cf0a6269 Ran 0 tests containing 0 assertions. 0 failures, 0 errors.

borkdude15:02:18

Two potential problems: Don't use hyphens in your file name: rename to:

test_notify_tag.clj

borkdude15:02:33

and also write:

(ns test-notify-tag)
at the top of the file

borkdude15:02:48

Also for the test runner you need to add the bb/test directory to the test directories

Hanisha Jain15:02:01

updated (ns test-notify-tag (:require [clojure.test :refer [deftest is testing]])) file name now is test_notify_tag.clj edn updated:

{:paths ["bb" "."]

 :deps {}
 :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"]}
           :dirs ["bb/test"]
           :org.babashka/cli {:coerce {:nses [:symbol]
                                       :vars [:symbol]}}}}}

Hanisha Jain15:02:34

i think you meant to add dirs

borkdude16:02:14

also: extra-paths bb/test

borkdude16:02:22

they need to be the same

Hanisha Jain16:02:36

ok. I am gonna again attach updated stuff Cause runner says:

PS H:\Iroh\Devops\bb> bb test:bb

Running tests in #{"bb/test"}

Testing exec-c6db8cdf-d116-4bda-89b2-750d8d19507b

Ran 0 tests containing 0 assertions.
0 failures, 0 errors.

borkdude16:02:00

Perhaps it's a Windows issue. Try bb\\test

Hanisha Jain16:02:07

Added and also updated file name

:dirs

Hanisha Jain16:02:40

you wanna say try "bb\\test" as command?

borkdude16:02:53

no, as the directory names. or are you running under WSL2?

Hanisha Jain16:02:07

path name! that makes sense

Hanisha Jain16:02:00

well, still same logs. 0 test ran

Hanisha Jain16:02:15

I have required clojure.test and even defined test with deftest

borkdude16:02:21

share your code on github (or a similar repro) and I'll have a look. it's really difficult to diagnose this problem without looking at the specific code

borkdude16:02:25

screenshots don't help

Hanisha Jain16:02:53

i'll do that. rn

borkdude16:02:16

yes, I'll take a look

borkdude17:02:01

Change bb.edn to this:

{:paths ["."]

 :deps {}
 :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)
           :dirs ["test"]
           :org.babashka/cli {:coerce {:nses [:symbol]
                                       :vars [:symbol]}}}}}

borkdude17:02:14

and then bb test:bb:

Running tests in #{"test"}

Testing notify-tag-test

Ran 1 tests containing 4 assertions.
0 failures, 0 errors.

Hanisha Jain17:02:14

this worked! thanks! again

Hanisha Jain17:02:46

this all makes sense! update in the path and dirs

Hanisha Jain17:02:08

cleaner and better. Reasonable! Thank again @U04V15CAJ

👍 1