bensu / doo

doo is a library and lein plugin to run cljs.test on different js environments.
Eclipse Public License 1.0
324 stars 63 forks source link

No namespace doo.runner error #49

Closed arichiardi closed 8 years ago

arichiardi commented 8 years ago

Hello @bensu and again thanks for this refactoring! First of all, my conf:


:plugins [[lein-cljsbuild "1.1.0"]
              [lein-figwheel "0.4.1" :exclusions [cider/cider-nrepl]]
              [lein-doo "0.1.6-SNAPSHOT"]]

  :clean-targets ^{:protect false} ["resources/public/js/compiled" "target" "out"]
  :hooks [leiningen.cljsbuild]
  :source-paths ["src/clj"]

  :cljsbuild {:builds [{:id "dev"
                        :source-paths ["src/cljs" "test/cljs"]
                        :figwheel {:on-jsload "launcher.test/run"
                                   :css-dirs ["resources/public/styles"]}
                        :compiler {:main "cljs-browser-repl.core"  ;; https://github.com/bensu/doo/wiki/Working-with-Figwheel
                                   :output-to "resources/public/js/compiled/cljs-browser-repl.js"
                                   :output-dir "resources/public/js/compiled/out"
                                   :asset-path "js/compiled/out"
                                   :optimizations :none
                                   :source-map-timestamp true}}
                       {:id "test"
                        :source-paths ["src/cljs" "test/cljs"]
                        :compiler {:main launcher.runner
                                   :output-to "resources/private/test/compiled/cljs-browser-repl.js"
                                   :pretty-print false}}
...

When I launch lein figwheel dev I receive a big:

Caused by: clojure.lang.ExceptionInfo: No such namespace: doo.runner, could not locate doo/runner.cljs, doo/runner.cljc, or Closure namespace "doo.runner"
 at clojure.core$ex_info.invoke (core.clj:4593)

clojure.lang.ExceptionInfo: No such namespace: doo.runner, could not locate doo/runner.cljs, doo/runner.cljc, or Closure namespace "doo.runner" {:tag :cljs/analysis-error}
    at clojure.core$ex_info.invoke(core.clj:4593)
    at cljs.analyzer$error.invoke(analyzer.cljc:562)
    at cljs.analyzer$error.invoke(analyzer.cljc:560)
    at cljs.analyzer$analyze_deps.invoke(analyzer.cljc:1668)
    at cljs.analyzer$ns_side_effects.invoke(analyzer.cljc:2504)
    at cljs.analyzer$analyze_STAR_$fn__2094.invoke(analyzer.cljc:2585)
    at clojure.lang.PersistentVector.reduce(PersistentVector.java:333)
    at clojure.core$reduce.invoke(core.clj:6518)
    at cljs.analyzer$analyze_STAR_.invoke(analyzer.cljc:2585)
    at cljs.analyzer$analyze.invoke(analyzer.cljc:2600)
    at cljs.analyzer$analyze_file$fn__2145.invoke(analyzer.cljc:2844)
    at cljs.analyzer$analyze_file.invoke(analyzer.cljc:2839)
    at figwheel_sidecar.repl$analyze_build.invoke(repl.clj:242)
    at figwheel_sidecar.repl$analyze_builds.invoke(repl.clj:247)
    at figwheel_sidecar.repl$run_autobuilder_helper.invoke(repl.clj:295)
    at figwheel_sidecar.repl$start_autobuild.invoke(repl.clj:366)
    at figwheel_sidecar.repl$run_autobuilder.invoke(repl.clj:576)
    at user$eval12982.invoke(form-init8065958100227564854.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:6782)
    at clojure.lang.Compiler.eval(Compiler.java:6772)
    at clojure.lang.Compiler.load(Compiler.java:7227)
    at clojure.lang.Compiler.loadFile(Compiler.java:7165)
    at clojure.main$load_script.invoke(main.clj:275)
    at clojure.main$init_opt.invoke(main.clj:280)
    at clojure.main$initialize.invoke(main.clj:308)
    at clojure.main$null_opt.invoke(main.clj:343)
    at clojure.main$main.doInvoke(main.clj:421)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:383)
    at clojure.lang.AFn.applyToHelper(AFn.java:156)
    at clojure.lang.Var.applyTo(Var.java:700)
    at clojure.main.main(main.java:37)

Any workaround?

arichiardi commented 8 years ago

Ok a workaround is to have the doo runner in some other source path, like so:

{:id "dev"
  :source-paths ["src/cljs" "test/cljs"]
  :figwheel {:on-jsload "launcher.test/run"
                  :css-dirs ["resources/public/styles"]}
 :compiler {:main cljs-browser-repl.core
                  :output-to "resources/public/js/compiled/cljs-browser-repl.js"
                  :output-dir "resources/public/js/compiled/out"
                   :asset-path "js/compiled/out"
                   :optimizations :none
                   :source-map-timestamp true}}
{:id "test"
    :source-paths ["src/cljs" "test/doo"] <<--- This is a different path
    :compiler {:main 'launcher.runner
                     :output-to "resources/private/test/compiled/cljs-browser-repl.js"
                      :pretty-print false}}
bensu commented 8 years ago

Hi Andrea!

There are two possible questions here:

  1. How to run a Figwheel build with the test runner (the file that contains doo/run-tests)?
  2. How to avoid including doo/run-tests in your Figwheel build?

Which one is it?

The error occurs because Figwheel doesn't have the [doo "0.1.6-SNAPSHOT"] dependency, which is dynamically added by the plugin lein-doo here.

arichiardi commented 8 years ago

The answer to number 2 is exactly my workaround...but there must be a better way. I am actually running my test inside the browser (printing the results to console) using a standard run that uses the standard run-tests. I don't think number 1 is that easy to achieve. But I have not explored the code.

If doo adds itself at runtime of course it cannot be seen by whoever is compiling code. This is not good for me and should be corrected, it should not interfere, aka it should be possible to have the two working at the same time..I will investigate anyways :)

bensu commented 8 years ago

Hi @arichiardi

After looking at this again I realize you could just solve it by adding [doo 0.1.6-SNAPSHOT] to your list of dev dependencies, and things would properly compile. If you are still having trouble with this, can you try it out?

Otherwise, feel free to close this issue.

arichiardi commented 8 years ago

Yes it was long time ago and solved, thanks!