Olical / cljs-test-runner

Discover and run your ClojureScript tests
https://clojars.org/olical/cljs-test-runner
The Unlicense
86 stars 16 forks source link

namespaces undetected #39

Closed ccfontes closed 3 years ago

ccfontes commented 3 years ago

Node: v15.5.1 test directory: test/ olical/cljs-test-runner: 3.8.0

In my app, run clj -Atest (alias is :test), but no test namespaces are detected.

Then tried to repro in this repo using your examples, but couldn't get the tests working, so lets start from here.

For that added alias :test from the readme to deps.edn, resulting in:

{:deps {org.clojure/clojure {:mvn/version "1.10.1"}
        org.clojure/clojurescript {:mvn/version "1.10.773"}
        org.clojure/tools.namespace {:mvn/version "1.0.0"}
        org.clojure/tools.cli {:mvn/version "1.0.194"}
        ingesolvoll/doo {:mvn/version "0.2.0"}}
 :aliases {:test {:extra-deps {olical/cljs-test-runner {:mvn/version "3.8.0"}}
                  :main-opts ["-m" "cljs-test-runner.main"]}
           :dev {:extra-paths ["test" "other-tests" "cljs-test-runner-out/gen"]}}}

Finally run clj -Atest, but get this:

WARNING: Use of :main-opts with -A is deprecated. Use -M instead.
#error {
 :cause No such namespace: example.partial-test, could not locate example/partial_test.cljs, example/partial_test.cljc, or JavaScript source providing "example.partial-test" (Please check that namespaces with dashes use underscores in the ClojureScript file name) in file cljs-test-runner-out/gen/cljs_test_runner/gen.cljs
 :data {:tag :cljs/analysis-error}
 :via
 [{:type clojure.lang.ExceptionInfo
   :message failed compiling file:cljs-test-runner-out/gen/cljs_test_runner/gen.cljs
   :data {:file #object[java.io.File 0x5fc42998 cljs-test-runner-out/gen/cljs_test_runner/gen.cljs], :clojure.error/phase :compilation}
   :at [cljs.compiler$compile_file$fn__3895 invoke compiler.cljc 1724]}
  {:type clojure.lang.ExceptionInfo
   :message nil
   :data #:clojure.error{:source nil, :line nil, :column nil, :phase :compilation}
   :at [cljs.analyzer$analyze invokeStatic analyzer.cljc 4260]}
  {:type clojure.lang.ExceptionInfo
ple/partial_test.cljs, example/partial_test.cljc, or JavaScript source providing "example.partial-test" (Please check that namespaces with dashes use underscores in the ClojureScript file name) in file cljs-test-runner-out/gen/cljs_test_runner/gen.cljs
   :data {:tag :cljs/analysis-error}
   :at [cljs.analyzer$error invokeStatic analyzer.cljc 762]}]
 :trace
 [[cljs.analyzer$error invokeStatic analyzer.cljc 762]
  [cljs.analyzer$error invoke analyzer.cljc 758]
  [cljs.analyzer$error invokeStatic analyzer.cljc 760]
  [cljs.analyzer$error invoke analyzer.cljc 758]
  [cljs.analyzer$analyze_deps invokeStatic analyzer.cljc 2636]
  [cljs.analyzer$analyze_deps invoke analyzer.cljc 2605]
  [cljs.analyzer$ns_side_effects invokeStatic analyzer.cljc 4122]
  [cljs.analyzer$ns_side_effects invoke analyzer.cljc 4117]
  [cljs.analyzer$analyze_STAR_$fn__2772 invoke analyzer.cljc 4244]
  [clojure.lang.PersistentVector reduce PersistentVector.java 343]
  [clojure.core$reduce invokeStatic core.clj 6827]
.core$reduce invoke core.clj 6810]
  [cljs.analyzer$analyze_STAR_ invokeStatic analyzer.cljc 4244]
  [cljs.analyzer$analyze_STAR_ invoke analyzer.cljc 4235]
  [cljs.analyzer$analyze invokeStatic analyzer.cljc 4263]
  [cljs.analyzer$analyze invoke analyzer.cljc 4246]
  [cljs.compiler$emit_source invokeStatic compiler.cljc 1542]
  [cljs.compiler$emit_source invoke compiler.cljc 1515]
  [cljs.compiler$compile_file_STAR_$fn__3864 invoke compiler.cljc 1627]
  [cljs.compiler$with_core_cljs invokeStatic compiler.cljc 1435]
  [cljs.compiler$with_core_cljs invoke compiler.cljc 1424]
  [cljs.compiler$compile_file_STAR_ invokeStatic compiler.cljc 1611]
  [cljs.compiler$compile_file_STAR_ invoke compiler.cljc 1604]
  [cljs.compiler$compile_file$fn__3895 invoke compiler.cljc 1709]
  [cljs.compiler$compile_file invokeStatic compiler.cljc 1684]
  [cljs.compiler$compile_file invoke compiler.cljc 1660]
  [cljs.closure$compile_file invokeStatic closure.clj 663]
1][cljs.closure$compile_file invoke closure.clj 64
  [cljs.closure$fn__5400 invokeStatic closure.clj 737]
  [cljs.closure$fn__5400 invoke closure.clj 731]
  [cljs.closure$fn__5313$G__5306__5320 invoke closure.clj 559]
  [cljs.closure$compile_sources$iter__5526__5530$fn__5531 invoke closure.clj 1107]
  [clojure.lang.LazySeq sval LazySeq.java 42]
  [clojure.lang.LazySeq seq LazySeq.java 51]
  [clojure.lang.Cons next Cons.java 39]
  [clojure.lang.RT next RT.java 713]
  [clojure.core$next__5386 invokeStatic core.clj 64]
  [clojure.core$dorun invokeStatic core.clj 3142]
  [clojure.core$doall invokeStatic core.clj 3148]
  [clojure.core$doall invoke core.clj 3148]
  [cljs.closure$compile_sources invokeStatic closure.clj 1103]
  [cljs.closure$compile_sources invoke closure.clj 1092]
  [cljs.closure$build invokeStatic closure.clj 3132]
  [cljs.closure$build invoke closure.clj 3040]
  [cljs.build.api$build invokeStatic api.clj 227]
  [cljs.build.api$build invoke api.clj 210]
  [cljs.build.api$build invokeStatic api.clj 216]
d invoke api.clj 210]l
  [cljs_test_runner.main$test_cljs_namespaces_in_dir invokeStatic main.clj 163]
  [cljs_test_runner.main$test_cljs_namespaces_in_dir invoke main.clj 123]
  [cljs_test_runner.main$_main invokeStatic main.clj 228]
  [cljs_test_runner.main$_main doInvoke main.clj 219]
  [clojure.lang.RestFn invoke RestFn.java 397]
  [clojure.lang.AFn applyToHelper AFn.java 152]
  [clojure.lang.RestFn applyTo RestFn.java 132]
  [clojure.lang.Var applyTo Var.java 705]
  [clojure.core$apply invokeStatic core.clj 665]
  [clojure.main$main_opt invokeStatic main.clj 514]
  [clojure.main$main_opt invoke main.clj 510]
  [clojure.main$main invokeStatic main.clj 664]
  [clojure.main$main doInvoke main.clj 616]
  [clojure.lang.RestFn applyTo RestFn.java 137]
  [clojure.lang.Var applyTo Var.java 705]
  [clojure.main main main.java 40]]}
Olical commented 3 years ago

Probably path related? I think adding :paths ["src" "test"] to your deps.edn should do the trick?

On Sun, 21 Feb 2021 at 11:36, Carlos notifications@github.com wrote:

Node: v15.5.1 test directory: test/ olical/cljs-test-runner: 3.8.0

In my app, run clj -Atest (alias is :test), but no test namespaces are detected.

Then tried to repro in this repo using your examples, but couldn't get the tests working, so lets start from here.

For that added alias :test from the readme to deps.edn, resulting in:

{:deps {org.clojure/clojure {:mvn/version "1.10.1"} org.clojure/clojurescript {:mvn/version "1.10.773"} org.clojure/tools.namespace {:mvn/version "1.0.0"} org.clojure/tools.cli {:mvn/version "1.0.194"} ingesolvoll/doo {:mvn/version "0.2.0"}} :aliases {:test {:extra-deps {olical/cljs-test-runner {:mvn/version "3.8.0"}} :main-opts ["-m" "cljs-test-runner.main"]} :dev {:extra-paths ["test" "other-tests" "cljs-test-runner-out/gen"]}}}

Finally run clj -Atest, but get this:

WARNING: Use of :main-opts with -A is deprecated. Use -M instead.

error {

:cause No such namespace: example.partial-test, could not locate example/partial_test.cljs, example/partial_test.cljc, or JavaScript source providing "example.partial-test" (Please check that namespaces with dashes use underscores in the ClojureScript file name) in file cljs-test-runner-out/gen/cljs_test_runner/gen.cljs :data {:tag :cljs/analysis-error} :via [{:type clojure.lang.ExceptionInfo :message failed compiling file:cljs-test-runner-out/gen/cljs_test_runner/gen.cljs :data {:file #object[java.io.File 0x5fc42998 cljs-test-runner-out/gen/cljs_test_runner/gen.cljs], :clojure.error/phase :compilation} :at [cljs.compiler$compile_file$fn3895 invoke compiler.cljc 1724]} {:type clojure.lang.ExceptionInfo :message nil :data #:clojure.error{:source nil, :line nil, :column nil, :phase :compilation} :at [cljs.analyzer$analyze invokeStatic analyzer.cljc 4260]} {:type clojure.lang.ExceptionInfo ple/partial_test.cljs, example/partial_test.cljc, or JavaScript source providing "example.partial-test" (Please check that namespaces with dashes use underscores in the ClojureScript file name) in file cljs-test-runner-out/gen/cljs_test_runner/gen.cljs :data {:tag :cljs/analysis-error} :at [cljs.analyzer$error invokeStatic analyzer.cljc 762]}] :trace [[cljs.analyzer$error invokeStatic analyzer.cljc 762] [cljs.analyzer$error invoke analyzer.cljc 758] [cljs.analyzer$error invokeStatic analyzer.cljc 760] [cljs.analyzer$error invoke analyzer.cljc 758] [cljs.analyzer$analyze_deps invokeStatic analyzer.cljc 2636] [cljs.analyzer$analyze_deps invoke analyzer.cljc 2605] [cljs.analyzer$ns_side_effects invokeStatic analyzer.cljc 4122] [cljs.analyzer$ns_side_effects invoke analyzer.cljc 4117] [cljs.analyzer$analyzeSTAR$fn2772 invoke analyzer.cljc 4244] [clojure.lang.PersistentVector reduce PersistentVector.java 343] [clojure.core$reduce invokeStatic core.clj 6827] .core$reduce invoke core.clj 6810] [cljs.analyzer$analyzeSTAR invokeStatic analyzer.cljc 4244] [cljs.analyzer$analyzeSTAR invoke analyzer.cljc 4235] [cljs.analyzer$analyze invokeStatic analyzer.cljc 4263] [cljs.analyzer$analyze invoke analyzer.cljc 4246] [cljs.compiler$emit_source invokeStatic compiler.cljc 1542] [cljs.compiler$emit_source invoke compiler.cljc 1515] [cljs.compiler$compile_fileSTAR$fn3864 invoke compiler.cljc 1627] [cljs.compiler$with_core_cljs invokeStatic compiler.cljc 1435] [cljs.compiler$with_core_cljs invoke compiler.cljc 1424] [cljs.compiler$compile_fileSTAR invokeStatic compiler.cljc 1611] [cljs.compiler$compile_fileSTAR invoke compiler.cljc 1604] [cljs.compiler$compile_file$fn3895 invoke compiler.cljc 1709] [cljs.compiler$compile_file invokeStatic compiler.cljc 1684] [cljs.compiler$compile_file invoke compiler.cljc 1660] [cljs.closure$compile_file invokeStatic closure.clj 663] 1][cljs.closure$compile_file invoke closure.clj 64 [cljs.closure$fn5400 invokeStatic closure.clj 737] [cljs.closure$fn5400 invoke closure.clj 731] [cljs.closure$fn5313$G53065320 invoke closure.clj 559] [cljs.closure$compile_sources$iter55265530$fn5531 invoke closure.clj 1107] [clojure.lang.LazySeq sval LazySeq.java 42] [clojure.lang.LazySeq seq LazySeq.java 51] [clojure.lang.Cons next Cons.java 39] [clojure.lang.RT next RT.java 713] [clojure.core$next__5386 invokeStatic core.clj 64] [clojure.core$dorun invokeStatic core.clj 3142] [clojure.core$doall invokeStatic core.clj 3148] [clojure.core$doall invoke core.clj 3148] [cljs.closure$compile_sources invokeStatic closure.clj 1103] [cljs.closure$compile_sources invoke closure.clj 1092] [cljs.closure$build invokeStatic closure.clj 3132] [cljs.closure$build invoke closure.clj 3040] [cljs.build.api$build invokeStatic api.clj 227] [cljs.build.api$build invoke api.clj 210] [cljs.build.api$build invokeStatic api.clj 216] d invoke api.clj 210]l [cljs_test_runner.main$test_cljs_namespaces_in_dir invokeStatic main.clj 163] [cljs_test_runner.main$test_cljs_namespaces_in_dir invoke main.clj 123] [cljs_test_runner.main$_main invokeStatic main.clj 228] [cljs_test_runner.main$_main doInvoke main.clj 219] [clojure.lang.RestFn invoke RestFn.java 397] [clojure.lang.AFn applyToHelper AFn.java 152] [clojure.lang.RestFn applyTo RestFn.java 132] [clojure.lang.Var applyTo Var.java 705] [clojure.core$apply invokeStatic core.clj 665] [clojure.main$main_opt invokeStatic main.clj 514] [clojure.main$main_opt invoke main.clj 510] [clojure.main$main invokeStatic main.clj 664] [clojure.main$main doInvoke main.clj 616] [clojure.lang.RestFn applyTo RestFn.java 137] [clojure.lang.Var applyTo Var.java 705] [clojure.main main main.java 40]]}

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Olical/cljs-test-runner/issues/39, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACM6XIG6JGBEZMA5GYCBUTTADV35ANCNFSM4X64WGEA .

ccfontes commented 3 years ago

Still no namespaces detected when adding test directory to :paths. Also, does this mean it'll ship the tests? Btw, I didn't add it before, because in your blog post mentioned this:

.. one difference is that we don’t need to add our test directory to the classpath.

Maybe just outdated instructions?

This is the test file (app/core.cljs):

(ns app.core
  (:require [cljs.test :as t]))

(t/deftest bla
  (t/is true))

Tried some variants of requiring clojure.test to no avail.

Alias:

:test {:extra-deps {olical/cljs-test-runner {:mvn/version "3.8.0"}}
       :main-opts ["-m" "cljs-test-runner.main"]}

I'll attempt a minimal repro in a public repo when I have the time.

Olical commented 3 years ago

Sorry I just noticed you had the directory in your extra-paths of your test alias, replied via email on the go in the hope it fixed the issue but didn't read properly I guess :grimacing:

Do your test namespaces end in -test? Because that's a requirement by default but is configurable I think :thinking: (sorry about the vagueness, this project and even CLJS testing in general isn't super fresh in my head right now!)

https://github.com/Olical/cljs-test-runner/blob/a9cc21916f32fb6caa9f54e349e7cc32b199b0c2/src/cljs_test_runner/main.clj#L190-L194

Yeah, you can modify this to match any namespace naming format if you want, maybe that's the issue?

ccfontes commented 3 years ago

No worries, and much appreciated for the super quick reply.

My namespaces don't end with that -test suffix. I must have missed it in the documentation. I'm fine with having the suffix, so no need to modify :default-desc.

Will try your fix first thing tomorrow morning and let you know (already 11PM here).

ccfontes commented 3 years ago

-test suffix works:

❯ clj -M:test

Testing app.core-test

Ran 1 tests containing 1 assertions.
0 failures, 0 errors.

Thanks!