Fork me on GitHub
#babashka
<
2019-12-29
>
nate_clojurians03:12:41

having a test library for babashka might be nice

nate_clojurians03:12:11

trying to think about how to include tests in the same script in an unobtrusive way, though

borkdude08:12:58

Yes, Iโ€™ve already said earlier this week that I want to port clojure.test, but that will take some time

borkdude16:12:01

@nate_clojurians Added a test library for babashka: https://github.com/borkdude/spartan.test

lee17:12:03

@borkdude, maybe you should change your tagline to โ€œwe are borkdude, we create awesome toolsโ€ because I canโ€™t imagine there is only one of you!

borkdude19:12:40

Made the output more like normal clojure.test:

FAIL in project.test/foo-test
expected: (= 2 (project/foo))
actual: (not (= 2 1))

borkdude19:12:49

Now I can finally test this giant babashka script... https://github.com/borkdude/deps.clj

nate21:12:02

@borkdude Wow, it's amazing how much babashka can do!

nate_clojurians21:12:23

should the installer for https://github.com/borkdude/deps.clj install it as deps.exe on macos?

nate_clojurians21:12:08

sure looks like it

nate_clojurians21:12:35

probably should fix the examples in the readme, then

borkdude21:12:02

@nate_clojurians Where do you see a mistake in the README?

borkdude21:12:18

I called it deps.exe to distuingish it from the deps.clj script

nate_clojurians21:12:23

it says to use the "deps.clj" script

nate_clojurians21:12:31

huh, I'm confused then

borkdude21:12:38

yes, there is a deps.exe executable AND a deps.clj babashka script

borkdude21:12:54

you can use the latter if you already have babashka

borkdude21:12:37

deps.clj is just a text file that you can run with either clojure or babashka whereas deps.exe is a binary file

borkdude21:12:45

they do the same

nate_clojurians21:12:59

does deps.exe require java?

borkdude21:12:03

yes, both require java to invoke tools.deps

nate_clojurians21:12:38

I'm trying to make a babashka-focused project for more clojurish filesystem manipulation (since I keep copy/pasting the same stuff from script to script)

nate_clojurians21:12:01

I rather like this project but I don't think babashka supports everything in there https://github.com/Raynes/fs/blob/master/src/me/raynes/fs.clj

nate_clojurians21:12:41

and I was going to test that out now

borkdude21:12:48

Yeah, just let me know what you need and it'll be added if it makes sense

borkdude21:12:00

This project is developed mostly on a by need basis

borkdude21:12:43

Lazy evaluation ๐Ÿ˜‰

nate_clojurians21:12:57

it definitely makes sense ๐Ÿ™‚

nate_clojurians21:12:17

there are some things I don't like about that library, though

nate_clojurians21:12:30

and handling zips isn't really something I commonly need

nate_clojurians21:12:49

and it generally returns File objects instead of path as strings

nate_clojurians21:12:09

but maybe that's a better choice?

nate_clojurians21:12:40

I kind of want to always be dealing with one thing

nate_clojurians21:12:19

and sometimes this returns strings and sometimes it returns files

borkdude21:12:37

yeah, it depends. don't really know the answer

nate_clojurians21:12:46

I think I'll avoid the lisp curse and just get this working ๐Ÿ™‚

nate_clojurians21:12:49

first one:

Unable to resolve classname: .FilenameFilter

nate_clojurians21:12:31

it uses it for globbing when filtering lists of files

borkdude21:12:26

cool, can you make an issue for it? (adding more to it as you discover more, is fine)

nate_clojurians21:12:52

Total results: 665, showing 1 - 24

nate_clojurians21:12:00

maybe I should focus on using something like the clj-commons fs

nate_clojurians21:12:23

oh, that's the same thing. ha!

nate_clojurians21:12:43

File system utilities for Clojure. (forked from Raynes/fs)

borkdude22:12:10

Added io/resource to master now

borkdude22:12:54

bonus feature of the testing lib:

WARNING: no assertions were made in test borkdude.deps-test/describe-test

nate_clojurians22:12:09

I just found an issue

nate_clojurians22:12:20

(require '[ :as io])

(defmacro ^:private predicate [s path]
  `(if ~path
     (. ~path ~s)
     false))

(defn absolute?
  "Return true if `path` is absolute."
  [path]
  (predicate isAbsolute (io/file path)))

(prn (absolute? "README.md"))

nate_clojurians22:12:35

$ clj 
false
$ bb 
Don't know how to create ISeq from: clojure.lang.Symbol [at /Users/nsutton/Code/fs/test.bb, line 11, column 3]

nate_clojurians22:12:56

some kind of macro issue, it seems

borkdude23:12:08

can you test the macro with clojure first?

borkdude23:12:32

@nate_clojurians This works:

(require '[ :as io])
(defmacro ^:private predicate [s path]
  `(if ~path
     (~(symbol (str "." s)) ~path)
     false))
(defn absolute?
  "Return true if `path` is absolute."
  [path]
  (predicate isAbsolute (io/file path)))
(prn (absolute? "README.md"))

borkdude23:12:39

I'll look at the error tomorrow

borkdude23:12:02

if you can file an issue as a reminder, that would be cool

borkdude23:12:50

released 54 with io/resource now

borkdude23:12:11

Kind of meta: deps.clj / deps.exe now uses itself in the tests to build the classpath with a testing library on it and then invokes clojure or babashka to run them

nate_clojurians23:12:58

gah, the fs stuff relies on some apache stuff for zip so uhhh

nate_clojurians23:12:06

I think I'll need to make my own fs lib

borkdude23:12:30

is this for working with zip files?

nate_clojurians23:12:38

no, that's the thing

nate_clojurians23:12:17

it has facilities for it but it feels orthogonal to the lib

nate_clojurians23:12:36

or at least complementary but separate

borkdude23:12:46

this was added for clj-http-lite, because it needs to handle gzip compression I think

nate_clojurians23:12:42

this bit is tricky, too

nate_clojurians23:12:55

it fails to run the script because it can't resolve those classes

nate_clojurians23:12:03

but in clojure those seem to be resolved at runtime

nate_clojurians23:12:17

or at least that code implies it

nate_clojurians23:12:36

it seems like bb is checking that before it actually executes

borkdude23:12:52

hmm, yes, too early probably

nate_clojurians23:12:07

and IllegalArgumentException isn't resolvable on its own like in clojure

borkdude23:12:11

I've never seen import be used like that before ๐Ÿ™‚

nate_clojurians23:12:14

you need java.lang in front of it

nate_clojurians23:12:22

it's all a little nope

borkdude23:12:25

ok, that's an easy fix

borkdude23:12:35

(IllegalArgument)

nate_clojurians23:12:42

reify is missing

borkdude23:12:00

feel free to post more issues just in case I forgot. reify I'm not sure if I can make that work, haven't thought about it

nate_clojurians23:12:16

this is the list I have so far

Add:

* .FilenameFilter
* java.nio.file.LinkOption
* java.nio.file.CopyOption
* java.nio.file.attribute.FileAttribute
* java.lang.IllegalArgumentException (needs fully qualified name in babashka whereas in clj you can just use IllegalArgumentException)
* reify
* clojure.java.shell/with-sh-dir

borkdude23:12:29

sounds good

nate_clojurians23:12:41

filed issues 200 and 199