Fork me on GitHub
#figwheel
<
2020-07-31
>
johanatan18:07:30

hi, i'm using figwheel-main with deps.edn and trying to get command line tests working with the standard test_runner. I am getting an error that it cannot find my test-runner even though i have "test" as an "extra-paths" and the filename has an underscore where the hyphen is.

johanatan18:07:01

Namespace redacted.test-runner/redacted.test-runner does not exist

johanatan18:07:35

my filesystem structure is: <project_root>/test/redacted/test_runner.cljs

johanatan18:07:48

and that file contains the standard boilerplate for a test runner.

johanatan18:07:38

here is my deps.edn snippet:

:test  {:extra-paths ["test"]
                   :main-opts ["-m" "figwheel.main" "-m" redacted.test-runner]

johanatan18:07:19

can anyone help?

bhauman19:07:26

@johanatan that error is strange it says redacted.test-runner/redacted.test-runner

johanatan19:07:37

yep, it is strange πŸ™‚

bhauman19:07:08

is this just a ClojureScript compile error?

johanatan19:07:12

i change the deps.edn to be: redacted.test-runnerzzz and the zzz was repeated on both sides

johanatan19:07:44

i.e., it's definitely getting that token just from the deps.edn (i moved the test.cljs.edn out of the way and it isn't referenced via -co anyway)

bhauman19:07:11

whats in your test runner?

johanatan19:07:13

here's the full output:

12:07 $ clj -A:test
2020-07-31 12:07:54.932:INFO::main: Logging initialized @6157ms to org.eclipse.jetty.util.log.StdErrLog
Unexpected error (IllegalArgumentException) compiling at (REPL:1).
Namespace redacted.test-runner/redacted.test-runner does not exist. Please check that namespaces with dashes use underscores in the ClojureScript file name.

Full report at:
/var/folders/jz/920rhb8h8xj864001s7_grh80000gn/T/clojure-5208612209110040008.edn

johanatan19:07:55

12:08 $ cat test/redacted/test_runner.cljs 
───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       β”‚ File: test/redacted/test_runner.cljs
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   β”‚ ;; This test runner is intended to be run from the command line
   2   β”‚ (ns redacted.test-runner
   3   β”‚   (:require
   4   β”‚    ;; require all the namespaces that you want to test
   5   β”‚    [redacted.proj.spec-tests]
   6   β”‚    [figwheel.main.testing :refer [run-tests-async]]))
   7   β”‚ 
   8   β”‚ (defn -main [& args]
   9   β”‚   (run-tests-async 5000))
───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

bhauman19:07:55

hmmm ok now just comment out run-tests-async

bhauman19:07:11

so that it does nothing

bhauman19:07:55

I’m wondering if the macro is expanding to something bad

bhauman19:07:24

this seems like a pretty minimal case let me check it

bhauman19:07:46

@johanatan hmm I just generated a figwheel.main project and the test runner ran just fine

johanatan19:07:23

hmm, what else are we missing? is there some other input here that I haven't yet shared ?

johanatan19:07:45

i.e., something else on my system

johanatan19:07:06

how about my deps.edn dependency list ?

bhauman19:07:12

are you in the project root when you run the command?

johanatan19:07:21

yep, in the project root

johanatan19:07:29

here are my deps:

{org.clojure/clojure {:mvn/version "1.10.1"}
        org.clojure/clojurescript {:mvn/version "1.10.597"}
        devcards {:mvn/version "0.2.6"}
        reagent {:mvn/version "0.8.1"}
        re-frame {:mvn/version "0.10.8"}
        re-com {:mvn/version "2.6.0"}
        cljsjs/react {:mvn/version "16.8.4-0"}
        cljsjs/react-dom {:mvn/version "16.8.4-0"}
        cljsjs/react-popper {:mvn/version  "1.0.2-0"}
        cljsjs/react-transition-group {:mvn/version  "4.3.0-0"}
        com.andrewmcveigh/cljs-time {:mvn/version "0.5.2"}
        com.gfredericks/test.chuck {:mvn/version "0.2.10"}
        org.clojure/test.check {:mvn/version "0.10.0"}
        clj-commons/secretary {:mvn/version "1.2.4"}
        com.rpl/specter {:mvn/version "1.1.2"}
        com.gfredericks/exact {:mvn/version "0.1.11"}
        hiccup {:mvn/version "2.0.0-alpha2"}
        precise {:mvn/version "0.1.0"}
        camel-snake-kebab {:mvn/version "0.4.0"}
        org.clojure/core.match {:mvn/version "0.3.0"}
         {:mvn/version "1.3.0"}
        funcool/promesa {:mvn/version "3.0.0"}
        prismatic/schema {:mvn/version "1.1.12"}
        com.bhauman/figwheel-main {:mvn/version "0.2.3"}
        com.bhauman/rebel-readline {:mvn/version "0.1.4"}
        com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}
        nrepl/nrepl {:mvn/version "0.6.0"}
        cider/cider-nrepl {:mvn/version "0.22.1"}
        cider/piggieback {:mvn/version "0.4.1"}
        akiroz.re-frame/storage {:mvn/version "0.1.4"}
        testdouble/clojurescript.csv {:mvn/version "0.4.5"}
        cljsjs/proj4 {:mvn/version "2.5.0-0"}
        day8.re-frame/http-fx {:mvn/version "0.1.6"}
        re-frame-utils {:mvn/version "0.1.0"}
        day8.re-frame/re-frame-10x {:mvn/version "0.4.2"}}

johanatan19:07:54

and paths:

:paths ["src" "resources"]

bhauman19:07:55

and you are running clojure -A:test

johanatan19:07:02

clj -A:test actually

johanatan19:07:06

does it need to be clojure ?

bhauman19:07:07

that works

bhauman19:07:42

are you using the very latest clojure tools, because they just mae some big changes

johanatan19:07:52

no, i haven't updated in a while

johanatan19:07:07

and have had this problem for 6 months at least. just now getting around to trying to diagnose it

bhauman19:07:26

did you try clojure -m figwheel.main -m redacted.test-runner

johanatan19:07:51

yea, i tried that a while ago. let me try again

bhauman19:07:54

hmmm that’s a really old version of figwheel

johanatan19:07:13

oh hmm. perhaps i should upgrade?

bhauman19:07:15

try 0.2.11

bhauman19:07:29

and make sure you delete all the output files

bhauman19:07:45

there’s a new --clean flag

johanatan19:07:47

target/ or something else?

johanatan19:07:01

oops, hmm, i get a different error now

johanatan19:07:56

Error in command line args
-- Spec failed --------------------

  ["-m" "redacted.test-runner/redacted.test-runner"]
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

should be a CLJS namespace available on the classpath

__ Doc for -m --main _____

  Call the -main function from a namespace with args

-------------------------
Detected 1 error

johanatan19:07:04

actually same error, different / better formatting

bhauman19:07:20

that’s very strange

bhauman19:07:45

ok now just try it on the command line

bhauman19:07:56

clj -m figwheel.main -m redacted…

johanatan19:07:02

ok, just a sec

johanatan19:07:52

back to the original error format

johanatan19:07:01

hmm, actually slight difference

johanatan19:07:22

12:28 $ clojure -m figwheel.main -m redacted.test-runner 
2020-07-31 12:28:31.570:INFO::main: Logging initialized @6269ms to org.eclipse.jetty.util.log.StdErrLog
Unexpected error (IllegalArgumentException) compiling at (REPL:1).
Namespace redacted.test-runner does not exist. Please check that namespaces with dashes use underscores in the ClojureScript file name.

Full report at:
/var/folders/jz/920rhb8h8xj864001s7_grh80000gn/T/clojure-6073873970012598693.edn

johanatan19:07:33

do i need to specify the "test" path somehow ?

bhauman19:07:34

interesting

bhauman19:07:58

comment out the opts part of your test alias

bhauman19:07:13

somehow deps is munging your namespace

johanatan19:07:46

does it matter that "redacted" actually contains a number ?

johanatan19:07:52

like "redacted5"

bhauman19:07:12

but something is super wacky

bhauman19:07:09

@johanatan if you create an alias to just add the test path it should work

johanatan19:07:58

so... clojure -A:test -m figwheel.main -m redacted.test-runner

johanatan19:07:09

where the test alias only modifies path ?

bhauman19:07:16

your redacted.test-runner in your deps.edn file needs to have quotes around it

johanatan19:07:46

clojure -A:test -m figwheel.main -m rapid7.test-runner << this actually did work

johanatan19:07:16

yes, quotes in deps.edn worked

johanatan19:07:42

i had tried 'redacted.test-runner but didn't think to try "redacted.test-runner"

johanatan19:07:01

sorry for the huge time waste. i was afraid it was something simple like this

johanatan19:07:01

anyway, thanks so much for your help! @bhauman

johanatan20:07:48

how do we prevent the "eval timed out!" error? my tests successfully run (based on output i'm seeing in the browser's console log) but i always get the following error in the actual command line:

13:10 $ clj -A:test  
2020-07-31 13:10:22.336:INFO::main: Logging initialized @5506ms to org.eclipse.jetty.util.log.StdErrLog
[Figwheel] Validating figwheel-main.edn
[Figwheel] figwheel-main.edn is valid \(ツ)/
[Figwheel] Compiling build test to "target/public/cljs-out/test-main.js"
[Figwheel] Successfully compiled build test to "target/public/cljs-out/test-main.js" in 14.239 seconds.
Opening URL 
Eval timed out!
No stacktrace available.
Execution error (ExceptionInfo) at cljs.repl/evaluate-form (repl.cljc:578).
Eval timed out!

Full report at:
/var/folders/jz/920rhb8h8xj864001s7_grh80000gn/T/clojure-2697828571253767923.edn

johanatan20:07:10

(i tried both run-tests and run-test-async [the latter with a very high timeout value])

bhauman21:07:49

@johanatan you have to give it a bigger timeout!

bhauman21:07:10

change 5000 to something bigger

johanatan21:07:16

I gave it 120000 and yet the timeout occurred within 20 secs

johanatan21:07:37

And also the problem occurred with the synchronous version as well

bhauman21:07:10

oh the repl has a timeout

bhauman21:07:17

let’s see

bhauman21:07:16

@johanatan there is a :repl-eval-timeout that you can set in figwheel options

bhauman21:07:28

not sure if that will do it

bhauman21:07:51

oh and BTW there is a #figwheel-main channel thats probably better for this

johanatan21:07:52

Will migrate the conversation over to there if there is still a need after trying :repl-eval-timeout