figwheel

general discussion about figwheel, specific discussions in #figwheel-main and #lein-figwheel
johanatan 2020-07-31T18:34:30.096100Z

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.

johanatan 2020-07-31T18:35:01.096500Z

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

johanatan 2020-07-31T18:35:35.097100Z

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

johanatan 2020-07-31T18:35:48.097400Z

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

johanatan 2020-07-31T18:37:38.097800Z

here is my deps.edn snippet:

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

johanatan 2020-07-31T18:38:19.098100Z

can anyone help?

johanatan 2020-07-31T18:40:40.098400Z

@bhauman ^^

bhauman 2020-07-31T19:09:26.099900Z

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

johanatan 2020-07-31T19:09:37.100100Z

yep, it is strange πŸ™‚

bhauman 2020-07-31T19:10:08.101300Z

is this just a ClojureScript compile error?

johanatan 2020-07-31T19:10:12.101400Z

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

johanatan 2020-07-31T19:10:44.102100Z

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)

bhauman 2020-07-31T19:11:11.102800Z

whats in your test runner?

johanatan 2020-07-31T19:11:13.103Z

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

johanatan 2020-07-31T19:11:55.104100Z

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))
───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

bhauman 2020-07-31T19:12:55.104600Z

hmmm ok now just comment out run-tests-async

bhauman 2020-07-31T19:13:11.104900Z

so that it does nothing

bhauman 2020-07-31T19:13:55.105300Z

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

bhauman 2020-07-31T19:15:24.105700Z

this seems like a pretty minimal case let me check it

bhauman 2020-07-31T19:19:46.106700Z

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

johanatan 2020-07-31T19:20:23.107400Z

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

johanatan 2020-07-31T19:20:45.107800Z

i.e., something else on my system

johanatan 2020-07-31T19:21:06.108300Z

how about my deps.edn dependency list ?

bhauman 2020-07-31T19:21:12.108500Z

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

johanatan 2020-07-31T19:21:21.108700Z

yep, in the project root

johanatan 2020-07-31T19:21:29.109Z

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"}
        <http://thi.ng/color|thi.ng/color> {: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"}}

johanatan 2020-07-31T19:21:54.109500Z

and paths:

:paths ["src" "resources"]

bhauman 2020-07-31T19:21:55.109600Z

and you are running clojure -A:test

johanatan 2020-07-31T19:22:02.109800Z

clj -A:test actually

johanatan 2020-07-31T19:22:06.110100Z

does it need to be clojure ?

bhauman 2020-07-31T19:22:07.110200Z

that works

bhauman 2020-07-31T19:22:42.110900Z

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

johanatan 2020-07-31T19:22:52.111300Z

no, i haven't updated in a while

johanatan 2020-07-31T19:23:07.111900Z

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

bhauman 2020-07-31T19:23:26.112100Z

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

johanatan 2020-07-31T19:23:51.112600Z

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

bhauman 2020-07-31T19:23:54.112800Z

hmmm that’s a really old version of figwheel

johanatan 2020-07-31T19:24:13.113200Z

oh hmm. perhaps i should upgrade?

bhauman 2020-07-31T19:24:15.113300Z

try 0.2.11

johanatan 2020-07-31T19:24:18.113600Z

k

bhauman 2020-07-31T19:24:29.113900Z

and make sure you delete all the output files

bhauman 2020-07-31T19:24:45.114400Z

there’s a new --clean flag

johanatan 2020-07-31T19:24:47.114500Z

target/ or something else?

bhauman 2020-07-31T19:24:53.114700Z

target

johanatan 2020-07-31T19:24:56.114900Z

k

johanatan 2020-07-31T19:26:01.115700Z

oops, hmm, i get a different error now

johanatan 2020-07-31T19:26:56.116100Z

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

johanatan 2020-07-31T19:27:04.116500Z

actually same error, different / better formatting

bhauman 2020-07-31T19:27:12.116800Z

actually

bhauman 2020-07-31T19:27:20.117100Z

that’s very strange

bhauman 2020-07-31T19:27:45.117700Z

ok now just try it on the command line

bhauman 2020-07-31T19:27:56.118Z

clj -m figwheel.main -m redacted…

johanatan 2020-07-31T19:28:02.118200Z

ok, just a sec

johanatan 2020-07-31T19:28:52.119200Z

back to the original error format

johanatan 2020-07-31T19:29:01.119400Z

hmm, actually slight difference

johanatan 2020-07-31T19:29:22.120Z

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

bhauman 2020-07-31T19:29:31.120300Z

ahhhh

johanatan 2020-07-31T19:29:33.120600Z

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

bhauman 2020-07-31T19:29:34.120700Z

interesting

bhauman 2020-07-31T19:29:37.120900Z

yes

bhauman 2020-07-31T19:29:58.121300Z

comment out the opts part of your test alias

bhauman 2020-07-31T19:30:13.121700Z

somehow deps is munging your namespace

johanatan 2020-07-31T19:30:46.122400Z

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

johanatan 2020-07-31T19:30:52.122800Z

like "redacted5"

bhauman 2020-07-31T19:30:59.123100Z

no idea

johanatan 2020-07-31T19:31:03.123400Z

hehe

bhauman 2020-07-31T19:31:12.123600Z

but something is super wacky

bhauman 2020-07-31T19:32:09.124700Z

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

johanatan 2020-07-31T19:32:58.125400Z

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

johanatan 2020-07-31T19:33:09.125700Z

where the test alias only modifies path ?

bhauman 2020-07-31T19:33:13.125900Z

yes

bhauman 2020-07-31T19:33:55.126100Z

oh shit

bhauman 2020-07-31T19:34:16.126600Z

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

bhauman 2020-07-31T19:34:22.126900Z

@johanatan ^

johanatan 2020-07-31T19:34:25.127Z

ah!

johanatan 2020-07-31T19:34:46.127300Z

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

johanatan 2020-07-31T19:36:16.128200Z

yes, quotes in deps.edn worked

johanatan 2020-07-31T19:36:21.128400Z

😞

johanatan 2020-07-31T19:36:42.129Z

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

johanatan 2020-07-31T19:37:01.129400Z

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

johanatan 2020-07-31T19:43:01.129700Z

anyway, thanks so much for your help! @bhauman

johanatan 2020-07-31T20:12:48.130700Z

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 <http://localhost:9500>
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

johanatan 2020-07-31T20:13:10.131200Z

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

bhauman 2020-07-31T21:15:49.131600Z

@johanatan you have to give it a bigger timeout!

bhauman 2020-07-31T21:16:10.132300Z

change 5000 to something bigger

johanatan 2020-07-31T21:16:16.132600Z

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

johanatan 2020-07-31T21:16:37.133300Z

And also the problem occurred with the synchronous version as well

bhauman 2020-07-31T21:16:39.133400Z

oh weird

bhauman 2020-07-31T21:17:10.133600Z

oh the repl has a timeout

bhauman 2020-07-31T21:17:17.133800Z

let’s see

bhauman 2020-07-31T21:19:16.134400Z

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

bhauman 2020-07-31T21:19:28.134600Z

not sure if that will do it

bhauman 2020-07-31T21:19:51.135100Z

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

johanatan 2020-07-31T21:45:16.135600Z

Hehe ok.

johanatan 2020-07-31T21:45:52.136700Z

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