Fork me on GitHub
#nrepl
<
2019-02-09
>
pez10:02:59

This is a cider-nrepl question, let me know if this is not the right place to ask. Anyway: I am trying to fix a bug/shortcoming in Calva that when running tests for a namespace/file the tests for it’s test ns (same ns with -test appended) are not run unless that namespace is loaded. For project tests there is a load? key I can set to true on the message, but there is no such thing for namespace tests. I’ve tried to figure out from the Cider code how it is done there, but I do not quite follow what’s happening. Can I haz some pointers, pretty please? ❤️

dominicm10:02:23

There is a key which can load all project namespaces.

dominicm10:02:47

Maybe orchard could be updated to minimize how much it loads based on the size of the query?

dominicm10:02:08

But generally, loading project namespaces works.

pez11:02:41

Thanks! I’ll load all namespaces for now. However, Cider has commands for running tests only for loaded namespaces in the project (that’s what happens if you don’t pass that load? key to the test-all op). That indicates that Cider does not load all namespaces for running the namespace tests, or I am getting that wrong, maybe?

dominicm11:02:34

Oh. Maybe. I wrote this ages ago, so I've forgotten how it works.

dominicm11:02:02

Reading the source in orchard is the best bet

pez11:02:21

I’m trying, believe me! As my competitor, Andrey Lisin, says. 😃

dominicm12:02:02

Cider test just does this: :load-project-ns? load?

dominicm12:02:11

Iirc, that's what load did before.

pez12:02:15

No, didn’t find, thanks again! What I got from the cider-test code was that it only did that for running project tests, not when running tests for some given namespaces. But I could have gotten it wrong.

dominicm12:02:59

Those specific things are legacy, use the test-var-query instead

pez12:02:38

Ah, now we’re talking! Is there somewhere I can read up on these things?

dominicm13:02:40

Asking is probably it :D

dominicm13:02:00

I'm pretty bad at writing things down :)

dominicm13:02:24

I came up with this test var query stuff when I rewrote apropos to be more general

pez13:02:46

So, I am beginning to understand why you linked me to orchard/query… But I am not quite there yet, what is a var-query? What is an ns-query?

pez13:02:31

btw. Doing ns-load-all before running tests for a namespaces worked, but it is brutal and makes the first namespace test run take a long time in large projects.

dominicm13:02:40

Var-query is best documented on that orchard docstring, it's a data description for filtering vars/nss to be the target of an operation

pez13:02:14

I’ll read it more carefully this time then. 😃

dominicm13:02:31

Only test and apropos support it for now, but if you can think of somewhere to apply it, that would be cool

pez13:02:59

Looks like I will be able to use this to allow testing of the test under the cursor, right?

dominicm13:02:59

But you'll need to identify the test using regex, fireplace has one

dominicm13:02:01

Maybe refresh would be a cool place to apply this. You could refresh just your test namespaces...

pez13:02:39

So, now I run the namespace tests using test-var-query instead, that’s cool. But I still fail at finding the -test tests, because not loaded. Adding a truthful load-project-ns? to the ns-query doesn’t seem to do anything. This is how my op looks like right now (TypeScript):

op: "test-var-query", ns, id, session: this.sessionId, "var-query": {
                    "ns-query": {
                        exactly: [ns],
                        "load-project-ns?": true
                    }
                }

dominicm15:02:52

What does true become over bencode? You might want to use 1 or something

pez16:02:25

true works elsewhere. But I did try with 1 as well since that is what replant does. 😃 Looking at the query code, am I correct in reading it as it only considers load-project-ns? if project? also is true? https://github.com/clojure-emacs/orchard/blob/master/src/orchard/query.clj#L23

pez16:02:16

(Not that it works setting that to true as well, but anyway.)

dominicm16:02:27

It might be that is a bug :)

dominicm16:02:35

Up to us to define behaviour

dominicm16:02:51

I personally don't have a problem with that behaviour being changed. I don't think any users of cider would either. It wouldn't be an API change. If you wanted to be really crazy, you could grow the api to hold onto the old behaviour.

dominicm16:02:17

I didn't notice this behaviour particularly myself, but I always run with project set to true.

pez17:02:28

The strange thing is that it doesn’t have an effect for me to set both to true…

dominicm17:02:39

Double check how nrepl modified the value

pez17:02:16

Regardless, it does seem wrong that they should be coupled like that (if that is what they are).

dominicm17:02:11

I agree too :)

pez17:02:51

Yeah, I’ll peek into what happens to the values. But later, now family needs food. 😃 Thanks for the assistance so far!

dominicm17:02:22

So I think you are in the right place. All I can guess is that the code to load project ns isn't working in your context.

pez18:02:06

It is a bit extra strange that the ns-load-all op works, which uses the exact same function for loading… I think I am doing something wrong, but we’ll see.