Fork me on GitHub
#cider
<
2020-05-24
>
radicalmatt04:05:06

I'm finding that I am getting different test results when running the suite from inside CIDER through C-c C-t p than when I run them on the terminal through lein test . Has anyone run into this before? I think I'm missing some context on how tests work within CIDER possibly. Is C-c C-t p doing something wildly different than lein test?

dpsutton04:05:31

i don't believe so

dpsutton04:05:16

you mentioned that your tests were profile dependent. is it possible that you are running with different profiles? If not, is it possible that you are not reevaluating the code you need so lein test sees your updated code but your repl doesn't have new definitions re-evaled?

radicalmatt04:05:05

That's right, I am providing with-profile +my-profile to the cider-jack-in command that I am customizing through the C-u M-x cider-jack-in RET method here https://docs.cider.mx/cider/0.24/basics/up_and_running.html#_customizing_the_jack_in_command_behaviour. However, what is curious is that if I jack-in without the profile I will see the error I expect to see (and that I will get on ther terminal) if that profile is omitted. I'm seeing a new and diferent error in cider when I jack-in with the profile present.

dpsutton04:05:41

interesting. nothing springs to mind but i'm interested in what you track down

dpsutton04:05:09

and all files are saved and lein with-profile +my-profile test reports differently?

dpsutton04:05:34

and there's no test selectors involved? and doing this from a fresh cider-jack-in shows a different error?

radicalmatt04:05:17

yep, fresh nREPL - the terminal will run alltests successfully when that profile is provided. I'm wondering if the project itself is doing something profoundly strange that might be affecting the test runner (this is a project I am new to)

dpsutton04:05:58

what error are you getting by the way

dpsutton04:05:25

CIDER introduces a thing that throws if you accidentally do (is (= 1)) saying equality should need multiple arguments

dpsutton04:05:00

and i think there are some other libs that do that too. many humane-test-output or something similar

radicalmatt04:05:20

I am seeing some tests fail with an java.lang.IndexOutOfBoundsException error in weird looking situations, hm

radicalmatt04:05:58

actually in several (is (= x y)) type assertions

dpsutton04:05:39

sounds unrelated to what i was thinking

dpsutton04:05:01

can you poke those functions in the repl? maybe see what's going on?

radicalmatt04:05:14

some breakpoints might be illuminating, yeah - I'll dig into it

radicalmatt04:05:02

@if you're extremely bored you can clone https://github.com/cloverage/cloverage and run tests in CIDER with the +sample profile

dpsutton04:05:50

oh are you testing cloverage itself?

radicalmatt04:05:30

I am. Or, trying to do so within my emacs setup.

dpsutton04:05:45

so i cloned it and then lein test in cloverage/cloverage i got failures

radicalmatt04:05:19

you'll have to run with the lein with-profile +sample test - the sample profile for reasons lost to time is required

dpsutton04:05:20

what profile should i be using?

dpsutton04:05:07

interesting. i can repro but no idea why

dpsutton04:05:05

interestingly, from lein repl i get

dpsutton04:05:07

Ran 58 tests containing 175 assertions.

dpsutton04:05:14

but in cider test project i get

dpsutton04:05:22

Tested 9 namespaces
Ran 188 assertions, in 67 test functions

radicalmatt04:05:52

that's unsettling

dpsutton04:05:03

and

lein test cloverage.kahn-test

lein test cloverage.report-test

lein test cloverage.report.console-test

lein test cloverage.sample.dummy-sample

lein test cloverage.sample.multibyte-sample

lein test cloverage.sample.read-eval-sample

lein test cloverage.source-test
vs
cloverage.args-test
cloverage.coverage-test
cloverage.dependency-test
cloverage.instrument-test
cloverage.kahn-test
cloverage.report-test
cloverage.report.console-test
cloverage.sample.exercise-instrumentation
cloverage.source-test

radicalmatt04:05:23

so I just had tests succeed when being run from cider, but then fail on the next run; so clearly something very weird is happening here

radicalmatt04:05:53

notably what you mention, that it looks like there's a different set of namespaces being run

radicalmatt05:05:25

it's midnight and time to close the laptop - @ thanks for having a look

andre.peric22:05:50

Hi people. It seems that clojurescript won’t jack in properly if there’s some namespace it an invalid ns (like (ns ). That’s because of https://github.com/clojure-emacs/cider/blob/master/cider-connection.el#L264, (cider-util--clojure-buffers) ends up finding a file with this ns and it fails trying to get the ns name or something like that. Is this considered a bug? If so, I can open an issue with the stacktrace or even try to fix it (by ignoring the error, perhaps? Or printing a friendlier error message instead of letting it fail later with forward-sexp) (you might wonder how I end up having this wrong ns declaration. The reason is that I created a clj file with spacemacs/open-junk-file. As I used the clj extension, it automatically added (ns ) for me. This file was not part of any project, I only created it for pasting some clojure code that I intended to format. :shrug:)

dpsutton22:05:59

for sure open an issue. it seems strange to me that this would prevent jacking in. But this seemingly would prevent compiling and if you can't compile you usually can't load the output in a page so you don't connect your application. what is the repro here? figwheel/figwheel-main/-m cljs.main/shadow?

andre.peric22:05:38

Oh, sorry, it did jack in, actually. It created a repl buffer in a pending state or something like that (I could tell this from the buffer name). But I was unable to evaluate stuff.

andre.peric22:05:59

It’s a shadow-cljs project

dpsutton22:05:58

ok. the pending state means it hasn't connected to the application yet. and that's because there isn't a compilation output since its invalid code

dpsutton22:05:34

when you tried to evaluate stuff i imagine you got an error like "no connected application" or something similar?

andre.peric22:05:24

Let me see, I’ll reproduce it again

andre.peric22:05:26

This is the stacktrace:

Debugger entered--Lisp error: (scan-error "Containing expression ends prematurely" 5 6)
  scan-sexps(5 1)
  forward-sexp(1)
  clojure-forward-logical-sexp()
  clojure--find-ns-in-direction(backward)
  clojure-find-ns()
  cider-current-ns()
  cider-refresh-dynamic-font-lock()
  cider-mode(1)
  cider-enable-on-existing-clojure-buffers()
  #f(compiled-function () #<bytecode 0x477bb459>)()
  #f(compiled-function (buffer) #<bytecode 0x4770c08d>)(#<buffer *cider-repl nu/timeline:localhost:63972(pending-cljs)*>)
  #f(compiled-function (response) #<bytecode 0x4770c109>)((dict "id" "4" "session" "f0733cfc-31b2-4759-bb10-2416c787fa6f" "status" ("done")))
  #f(compiled-function (response) #<bytecode 0x4770c151>)((dict "id" "4" "session" "f0733cfc-31b2-4759-bb10-2416c787fa6f" "status" ("done")))
  nrepl--dispatch-response((dict "id" "4" "session" "f0733cfc-31b2-4759-bb10-2416c787fa6f" "status" ("done")))
  nrepl-client-filter(#<process nrepl-connection> "d2:id1:47:session36:f0733cfc-31b2-4759-bb10-2416c787fa6f5:value3:niled2:id1:42:ns11:shadow.user7:session36:f0733cfc-31b2-4759-bb10-2416c787fa6fed2:id1:47:session36:f0733cfc-31b2-4759-bb10-2416c787fa6f6:statusl4:doneee")
When I try to evaluate something, there’s no error. But nothing happens. When I try to use cider-switch-to-repl-buffer , it says user-error: No cljs REPLs in current session "<my-project-name>:localhost:64265"

dpsutton22:05:13

there are no cljs repls so that seems find. how did you find the stacktrace?

dpsutton22:05:18

what did you do to trigger an error?

dpsutton22:05:35

oh. i'm following now

dpsutton22:05:53

and do you have unbalanced parens in a buffer?

dpsutton22:05:01

but either way that function needs to catch errors

andre.peric22:05:32

I’m using toggle-debug-on-error > what did you do to trigger an error? It is thown just after cider-jack-in -> cljs -> shadow -> <profile>

dpsutton22:05:58

how badly broken is the file?

andre.peric22:05:58

> and do you have unbalanced parens in a buffer? The minimal file for reproducing it is (ns )

dpsutton22:05:08

interesting. i wouldn't expect that to throw a scan error

andre.peric22:05:32

Yeah Perhaps it assumes there’s a second form in ns 🤔 Well, I’ll open the issue then, as it looks legit

dpsutton22:05:52

i think this is a bug in clojure-mode

dpsutton22:05:25

clojure-find-ns() should never throw an error

dpsutton22:05:18

and clojure--find-ns-in-direction needs a (condition-case nil ... (scan-error nil))

andre.peric23:05:39

Hummm, yeah, agreed. Perhaps clojure-find-ns() should make it explicit that if there’s no ns, it would return nil. It’s not clear what’s the expected behaviour just by looking at the current docstring.

dpsutton23:05:58

I think that’s the thought. There’s lots of when’s and unless in there I think

dpsutton23:05:44

Check the cider find ns version as well. It was a big or statement

andre.peric23:05:35

Yeap Well, I just opened the issue here, since I’m not sure who should handle this: https://github.com/clojure-emacs/cider/issues/2849 Thanks for helping me, dpsutton

dpsutton23:05:20

You are welcome!