Fork me on GitHub
#clojurescript
<
2019-06-24
>
Olical09:06:41

I had a couple of questions around self-hosted CLJS if someone has some experience with it? 1. I'm under the impression you can override the line number / file path of the evaluation like you can with a line numbering pushback reader for eval in Clojure? 2. Could I make the self hosted ClojureScript inherit from the parent environment to pick up all dependencies in the outer context? Or is it supposed to be an isolated environment. I mainly just want to be able to set the line number and file path of an evaluation from within a ClojureScript REPL. I think I can only do that through some self hosting trickery, maybe I'm wrong there though :thinking_face: if anyone knows of some fun hacks I can do to change the line number within a CLJS REPL then I'm all ears!

thheller09:06:46

its not possible from within a CLJS REPL without first patching CLJS and adding the funtionality (like it was added to Clojure not long ago)

Olical09:06:23

Oh, I vaguely recall seeing those as bindings somewhere in Clojure. I wonder if it'd be worth submitting a patch for that for parity at some point... hmm.

Olical10:06:24

I'm worried that if I go down the self hosting route I'll just encounter different issues around dependency loading further down the line.

bru13:06:57

hello dear clojurescripters, is anybody around who can point me to how dynamically create tests in clojurescript? I’ve been fumbling with this for a while and I’m wondering if I’m looking at the problem the wrong way. The idea is that I have already a set of nicely formatted specifications, and I’d like, for each of them, to do the equivalent of (deftest test-name test-body).

vemv17:06:56

are you familiar with cljs.test/are?

bru17:06:45

hi! yes, but this case is a bit more involved: I need to test the result of async functions, and only one of those can live in each test (according to the documentation)

bru18:06:01

alas: > You cannot have more than one async test per deftest form or only the first one will run.

vemv18:06:23

I see! No idea from my side. Given (deftest test-name test-body) seems a pretty trivial macroexpansion, you could write that code yourself. Or if you have far too many specifications, you can create a one-off program that will (println (pr-str (list 'deftest (gensym) the-specification))) ...and you copy/paste the result into a file

bru18:06:13

actually the latter may be a good idea 🙂

nenadalm19:06:56

Hi. I have something like that (I think) in my toy project. Here is the data with name of the test, query to be executed and expected results: https://github.com/nenadalm/Warehouse/blob/721b17f24cc545e44a5bbb101d69f13f203a339e/frontend/test/warehouse/indexeddb_test.cljs#L44. Here all tests run: https://github.com/nenadalm/Warehouse/blob/721b17f24cc545e44a5bbb101d69f13f203a339e/frontend/test/warehouse/indexeddb_test.cljs#L309. I am running more cases in single test. After each case I run done-single function that when called last time, calls done (https://github.com/nenadalm/Warehouse/blob/721b17f24cc545e44a5bbb101d69f13f203a339e/frontend/test/warehouse/indexeddb_test.cljs#L317). Mocha (js test framework I've tried to imitate in this case) works in similar way: https://mochajs.org/#dynamically-generating-tests

bru13:06:09

(also, the fact that I’m not finding literature on the subject makes me think that it’s either obvious or obviously a bad idea)

aisamu14:06:31

Macros could do that, although not dynamically (they run at "compile" time)

bru14:06:47

yup, that is what I’m counting on (I should have said programmatically rather than dynamically). Anyway, I think I’m getting somewhere 🙂

oskarkv21:06:10

I'm working on a cljs app that has a dependency that is my own local utils lib in a .cljc file. I want to be able to make changes in the utils lib while working on my cljs app. So instead of adding it as a dependency in deps.edn, I symlinked it into the src directory. It works in the sense that I can use the lib, but if I change something in the utils.cljc file I can't see the changes in my cljs app's namespace. And I can't seem to just evaluate (with CIDER) the utils.cljc file/namespace at all. Anybody know what's wrong, and how I can make it work?

oskarkv22:06:13

Apparently symlinks don't work with CIDER, hm...

dpsutton22:06:10

in CIDER you can use sesman-link-with-X where X is buffer, directory, project. Should let you link the two

oskarkv22:06:36

oh, interesting

lilactown23:06:29

if you’re using deps.edn, you could just use a local root

oskarkv23:06:04

@lilactown But that doesn't make it reload when I change it, right?

oskarkv23:06:16

I used that before, but the symlink was my attempt to make the utils lib act as part of the app so that it would reload just like the app code.

lilactown23:06:54

I’m not sure. When I used shadow-cljs + deps.edn + local roots, my code does reload

lilactown23:06:24

It might have to do with other issues reloading cljc or macros

oskarkv23:06:06

@lilactown Or maybe it's shadow-cljs? I haven't used it

lilactown23:06:14

yeah, not super familiar with like deps.edn + figwheel or other setups