Giter VIP home page Giter VIP logo

cljs-test-runner's Introduction

cljs-test-runner Clojars Project

Run all of your ClojureScript tests with one simple command.

Inspired by Cognitect's test-runner for Clojure, it is designed to be used in conjunction with the Clojure CLI tool and a deps.edn file.

Under the hood it's building a test runner file, compiling everything and then executing the compiled tests with doo (using ingesolvoll's fork). Discovery of test namespaces is automatic, so no configuration is required.

Usage

In simple cases, you'll be able to execute your tests with something as succinct as the following line.

$ clojure -Sdeps '{:deps {olical/cljs-test-runner {:mvn/version "3.8.1"}}}' -m cljs-test-runner.main

Note: The generated test code is placed in the directory cljs-test-runner-out by default (configure with --out), you should add that to your .gitignore file.

It's likely that your tests will require dependencies and configuration that would become unwieldy in this format. You will need to add the dependency and --main (-m) parameter to your deps.edn file.

I recommend you put this under an alias such as test or cljs-test if that's already taken by your Clojure tests.

{:deps {org.clojure/clojure {:mvn/version "1.10.1"}
        org.clojure/clojurescript {:mvn/version "1.10.520"}}
 :aliases {:test {:extra-deps {olical/cljs-test-runner {:mvn/version "3.8.1"}}
                  :main-opts ["-m" "cljs-test-runner.main"]}}}

The following will then find, compile and execute your tests through node.

$ clojure -Atest

Testing example.partial-test

Testing example.yes-test

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

Configuration

You can configure the test runner with a few different flags, the most important one is --env (-x) which allows you to swap from node to phantom or chrome-headless if required. I would recommend sticking to node and using something like jsdom, but this does come down to preference and technical requirements.

$ clojure -Atest -x phantom

If you need to use foreign-libs or any cljs compiler flags that are not mirrored in cljs-test-runner's flags, you can put them into an EDN file and point to that file using the --compile-opts flag.

You can use --help to see the current flags and their default values.

$ clojure -Atest --help
  -d, --dir DIRNAME            test                  The directory containing your test files
  -n, --namespace SYMBOL                             Symbol indicating a specific namespace to test.
  -r, --namespace-regex REGEX  .*\-test$             Regex for namespaces to test. Only namespaces ending in '-test' are evaluated by default.
  -v, --var SYMBOL                                   Symbol indicating the fully qualified name of a specific test.
  -i, --include SYMBOL                               Run only tests that have this metadata keyword.
  -e, --exclude SYMBOL                               Exclude tests with this metadata keyword.
  -o, --out DIRNAME            cljs-test-runner-out  The output directory for compiled test code
  -x, --env ENV                node                  Run your tests in node, phantom, chrome-headless, lumo or planck.
  -w, --watch DIRNAME                                Directory to watch for changes (alongside the test directory). May be repeated.
  -c, --compile-opts PATH                            EDN file containing opts to be passed to the ClojureScript compiler.
  -D, --doo-opts PATH                                EDN file containing opts to be passed to doo.
  -V, --verbose                                      Flag passed directly to the ClojureScript compiler to enable verbose compiler output.
  -H, --help

Advanced compilation

To use Closure Compiler advanced optimisation levels you will need to create an EDN file like this:

{:optimizations :advanced}

Now when you run the following, your tests will be executed with advanced compilation:

clj -m cljs-test-runner.main -c ./config/advanced-compilation.edn

You can also directly inline the EDN using the -c flag:

clj -m cljs-test-runner.main -c '{:optimizations :advanced}'

There is a known issue with :whitespace, I just haven't invested the time into working out what it is. For now, stick to :none, :simple or :advanced, the original issue for optimisation levels breaking things is #16.

Bundle target

The new bundle target requires a 2-step process for compilation. One for building an index.js consumable by bundlers like webpack, and a second step for actually running the bundler. This requires you to specify 2 different targets.

In essence, this requires you to include the following in your doo.edn:

{:output-to "resources/public/js/main.js"}

Your CLJS compiler options should be according to the standard guide.

Gotchas

Paths

Make sure the directory (or directories!) containing your tests are on your Java class path. Specify this with a top level :paths key in your deps.edn file.

Lumo / Planck

To use Lumo or Planck, add the generated test runner to the :paths in your deps.edn:

:paths ["src" "test" "cljs-test-runner-out/gen"]

and set the environment:

-x lumo

or

-x planck

Unlicenced

Find the full unlicense in the UNLICENSE file, but here's a snippet.

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

Do what you want. Learn as much as you can. Unlicense more software.

cljs-test-runner's People

Contributors

aria42 avatar arichiardi avatar borkdude avatar eval avatar henryw374 avatar ingesolvoll avatar kongeor avatar kthu avatar mfikes avatar olical avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cljs-test-runner's Issues

Pass compiler options so that npm-deps can be used

Hi, Iโ€™m trying to find the simplest way to get jsdom working from the test runner. I did some thinking about the best approach and I came up with this: allow the user to pass compiler options, in the same way as the cljs.main runner:

clj -Atest -co '{:install-deps true :npm-deps {:jsdom "11.10.0"}}' 

What do you think of this approach? Iโ€™ve only ever really dabbled with ClojureScript before, so I may be completely off the mark. Happy to submit a PR if you think this is the right thing.

Support Planck

I'd like to use this test runner with Planck. Doo already supports planck it seems.

I tried adding a planck case to the code:

{:keys [target doo-env]} (case env
                                     :node {:target :nodejs
                                            :doo-env :node}
                                     :phantom {:target :browser
                                               :doo-env :phantom}
                                     :chrome-headless {:target :browser
                                                       :doo-env :chrome-headless}
                                     :planck {:doo-env :planck})

When I try to run the speculative tests, I see:

$ clojure -A:test:cljs-test-runner -x planck -v speculative.core-test/assoc-in-test
No such namespace: cljs-test-runner.gen, could not locate cljs_test_runner/gen.cljs, cljs_test_runner/gen.cljc, or JavaScript source providing "cljs-test-runner.gen" (Please check that namespaces with dashes use underscores in the ClojureScript file name)

Maybe doo needs to add cljs-test-runner-out to the planck classpath?

Exit code is always zero?

Hi @Olical!

Using your tool way more seriously now ๐Ÿ˜„

I noticed that looks like the exit code when tests are failing is still zero. Is there an option I need to enable to report a failure?

To be more clear, the call clojure -m cljs-test-runner.main is the one returning zero.

Orchestra incompatibility

Hello again @Olical! Hope you are having a good work/tranquil relaxing day ๐Ÿ˜„

So I think I have a weird problem and it seems somehow related to jeaye/orchestra#32.

Every time I try to execute a test that contains (orchestra/instrument), I get:

Change detected, recompiling ...
... done. Elapsed 0.908152501 seconds
/home/arichiardi/git/laputa/commit-event-fn/.cljs/laputa/commit_event_fn/event_store.js:170

eval (clojure.core/vec (clojure.core/sequence (clojure.core/seq (clojure.core/concat (clojure.core/list (quote laputa.commit-event-fn.event-store/validate-event)) ...))))))
                                                                                                         ^^^^^

SyntaxError: missing ) after argument list
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at global.CLOSURE_IMPORT_SCRIPT (/home/arichiardi/git/laputa/commit-event-fn/.cljs/goog/bootstrap/nodejs.js:88:13)

It seems like cljs-test-runner tries to read the standard output and therefore fails because of what orchestra writes to it.

Have metadata on fixtures

Hi @Olical!

I have possibly a feature request ๐Ÿ˜„

We use cljs-test-runner with --include so that we can skip executing tests like:

(deftest ^:integration my-integration-test
  ...)

It all works great but there is a problem: if I use use-fixture, that will be called and in our case it will have the side effect of requiring environment variables - I cannot mix integration with non-integration tests in the same namespace, which is the whole point of --include I guess.

One solution, and it is not a standard in Clojure core, would be to add metadata to the fixtures.

(use-fixtures  ^:integration  :each
  {:before es-fixture/safely-create-db!
   :after es-fixture/safely-drop-db!})

In this case the problem can be avoided.

Running tests at the REPL

With the Cognitect test runner, you can run all your tests while via the REPL by simply doing

(require '[cognitect.test-runner])
(cognitect.test-runner/test {})

I was wondering if the same could be done with cljs-test-runner.

An experiment shows that it is probably possible via a macro.

https://github.com/mfikes/cljs-test-runner/tree/repl

The output of this experiment is below.

Before delving into this too far, wanted to share and see what your thoughts are.

Mikes-iMac:cljs-bean mfikes$ clj -A:repl/node
ClojureScript 1.10.520
cljs.user=> (require 'cljs-bean.core-test)
nil
cljs.user=> (require 'cljs-test-runner.test-runner)
nil
cljs.user=> (cljs-test-runner.test-runner/run-tests {})
WARNING: Use of undeclared Var doo.runner/set-entry-point! at line 31 cljs-test-runner-out/gen/cljs_test_runner/gen.cljs
WARNING: Use of undeclared Var doo.runner/karma? at line 31 cljs-test-runner-out/gen/cljs_test_runner/gen.cljs
WARNING: Use of undeclared Var jx.reporter.karma/start at line 31 cljs-test-runner-out/gen/cljs_test_runner/gen.cljs

Testing cljs-bean.core-test
{:result true, :num-tests 100, :seed 1561756175726, :time-elapsed-ms 262, :test-var "roundtrip-1"}
{:result true, :num-tests 100, :seed 1561756175989, :time-elapsed-ms 144, :test-var "roundtrip-2"}
{:result true, :num-tests 100, :seed 1561756176133, :time-elapsed-ms 102, :test-var "roundtrip-3"}
{:result true, :num-tests 100, :seed 1561756176235, :time-elapsed-ms 91, :test-var "roundtrip-4"}

Ran 72 tests containing 510 assertions.
0 failures, 0 errors.
0

Read npm-deps from package json

Hi there!

One of the biggest pain points when working with ClojureScript core is to keep the :npm-deps map in sync with package.json.

What do you think if we added a cli option that enables reading and creating that map from a package.json in the current root or somewhere else?

It would be so nice because it would avoid keeping external .cljs.edn files around.

I could take care of this and provide a patch.

-c option and optimizations problem

Hi, when using the -c option. and when the opts file passed to that contains e.g. :optimizations :advanced or whitespace, or simple, no tests are run. Setting it to :none does work though.

Any ideas?

Thanks,
Henry

No test execution if :advanced and no runner out dir

If you don't yet have a cljs-test-runner-out dir, and you run tests with :advanced, then no tests are run.

Repro:

test/foo/core_test.cljs:

(ns foo.core-test
  (:require [clojure.test :refer [deftest is]]))

(deftest sample-test
  (is (== 1 1)))

deps.edn:

{:deps {org.clojure/clojurescript {:mvn/version "1.10.520"}}
 :aliases {:test {:extra-deps  {olical/cljs-test-runner {:mvn/version "3.5.0"}}
                  :extra-paths ["test" "cljs-test-runner-out/gen"]
                  :main-opts   ["-m" "cljs-test-runner.main"]}}}

Then running the tests produces no output:

$ clojure -A:test -c '{:optimizations :advanced}'

Running them a second time will:

$ clojure -A:test -c '{:optimizations :advanced}'

Testing foo.core-test

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

Upgrade doo and add firefox support

Hello,

thank you for your work on this.

I'm using this test runner without issues after having bumped doo's patch version. I've also added firefox support which can be convenient for cross browser testing. Latest versions of Chrome and FF are working fine at the moment with the karma test runner. Is it ok to create a PR with those two changes: master...kongeor:cljs-test-runner:master

Thanks!

Support :target :bundle

The new bundle target of clojurescript compiler breaks doo/cljs-test-runner. The problem is that the file named by :output-to in compiler config is an intermediate file to be consumed by webpack, usually named index.js. It is not ready te be evaled as normal JS. It's the file generated by webpack we're interested in, usually named main.js.

Figwheel solved this problem by introducing another config var, :final-output-to.

I forked doo myself and added a :output-to options to doo-opts, that overrides the compiler config one if present.

Change is rather small, you can find it here https://github.com/ingesolvoll/doo.

That repo also contains change necessary for it to be consumed as a git dep in deps.edn.

ReferenceError: $jscomp is not defined

deps.edn:

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

test.cljs.edn:

{:optimizations :none
 :pretty-print  false
 :closure-defines {goog.DEBUG true}}

Works with :simple optimizations.

Breaks like this with :whitespace optimizations:

โฏ clj -M:test -x chrome-headless
Chrome Headless 88.0.4324.182 (Mac OS 11.2.1) ERROR
  Uncaught ReferenceError: $jscomp is not defined
  at cljs-test-runner-out/cljs_test_runner.gen.js:7060:530

  ReferenceError: $jscomp is not defined
      at cljs-test-runner-out/cljs_test_runner.gen.js:7060:530

Breaks likes this with :none optimizations:

โฏ clj -M:test -x chrome-headless
23 02 2021 17:46:39.377:WARN [web-server]: 404: /cljs-test-runner-out/goog/deps.js
23 02 2021 17:46:39.388:WARN [web-server]: 404: /cljs-test-runner-out/cljs_deps.js
23 02 2021 17:46:39.421:WARN [web-server]: 404: /cljs-test-runner-out/cljs_deps.js
Chrome Headless 88.0.4324.182 (Mac OS 11.2.1) ERROR
  Uncaught ReferenceError: $jscomp is not defined
  at cljs-test-runner-out/node_modules/object-assign/index.js:4:155

  ReferenceError: $jscomp is not defined
      at cljs-test-runner-out/node_modules/object-assign/index.js:4:155

Chrome Headless 88.0.4324.182 (Mac OS 11.2.1) ERROR
  Uncaught ReferenceError: $jscomp is not defined
  at cljs-test-runner-out/node_modules/react/cjs/react.production.min.js:6:378

  ReferenceError: $jscomp is not defined
      at cljs-test-runner-out/node_modules/react/cjs/react.production.min.js:6:378

Chrome Headless 88.0.4324.182 (Mac OS 11.2.1) ERROR
  Uncaught ReferenceError: $jscomp is not defined
  at cljs-test-runner-out/node_modules/react/cjs/react.development.js:7:42

  ReferenceError: $jscomp is not defined
      at cljs-test-runner-out/node_modules/react/cjs/react.development.js:7:42
      at cljs-test-runner-out/node_modules/react/cjs/react.development.js:90:15

Chrome Headless 88.0.4324.182 (Mac OS 11.2.1) ERROR
  Uncaught ReferenceError: $jscomp is not defined
  at cljs-test-runner-out/node_modules/react-dom/cjs/react-dom.production.min.js:43:201

  ReferenceError: $jscomp is not defined
      at cljs-test-runner-out/node_modules/react-dom/cjs/react-dom.production.min.js:43:201

Chrome Headless 88.0.4324.182 (Mac OS 11.2.1) ERROR
  Uncaught ReferenceError: $jscomp is not defined
  at cljs-test-runner-out/node_modules/react-dom/cjs/react-dom.development.js:35:171

  ReferenceError: $jscomp is not defined
      at cljs-test-runner-out/node_modules/react-dom/cjs/react-dom.development.js:35:171
      at cljs-test-runner-out/node_modules/react-dom/cjs/react-dom.development.js:989:15

Request for information on how to report exceptions.

Hi, thank you for the fantastic library, this is very useful!

This isn't really an issue so much as a question, sorry I wasn't sure where to ask. Please feel free to close this issue immediately.

When I get an exception inside a test, it gets swallowed like so:

ERROR in (defrule-test) (TypeError:NaN:NaN)
Uncaught exception, not in assertion.
expected: nil
  actual: #object[TypeError TypeError: Cannot read property 'name' of null]

The easy workaround is I put the code outside a test and run it again to get info on where the problem occurred.

Conversely, sometimes I get exceptions thrown from spec that would really benefit from some interpretation. Is there a way for me to include figwheel style error formatting in my command-line test command?

Issue detecting test namespaces

I am having some issue in the replumb project with the runner.

Basically when I display the classpath, I see the folders there:

$ clojure -Srepro -A:dev:test:node -Spath
test/common:src/node:repl-demo/node/cljs:test/node:src/cljs:test/common:...

but the runner does only:

$ ./scripts/test
+ export NODE_ENV=dev
+ NODE_ENV=dev
+ output_dir=.cljs-test-runner
+ main_cmd='clojure -Srepro -A:dev:test:node -m cljs-test-runner.main -V  --out .cljs-test-runner  --env node'
+ watch_args=
+ [[ '' =~ --watch ]]
+ main_cmd+=' '
+ main_cmd+=' --namespace replumb.cache-test'
+ clojure -Srepro -A:dev:test:node -m cljs-test-runner.main -V --out .cljs-test-runner --env node --namespace replumb.cache-test
Options passed to ClojureScript compiler: {:output-dir ".cljs-test-runner", :closure-warnings {:check-types :off, :check-variables :off}, :closure-defines {"cljs.core._STAR_target_STAR_" "nodejs"}, :ups-libs nil, :cache-analysis true, :closure-module-roots [], :optimizations :none, :ups-foreign-libs [], :verbose true, :aot-cache false, :ignore-js-module-exts [".css"], :output-to ".cljs-test-runner/test-runner.js", :preamble ["cljs/imul.js"], :ups-externs nil, :opts-cache "cljsc_opts.edn", :source-map true, :cache-analysis-format :transit, :target :nodejs, :main test.runner, :emit-constants nil}
Copying jar:file:/home/arichiardi/.m2/repository/org/clojure/core.rrb-vector/0.0.11/core.rrb-vector-0.0.11.jar!/clojure/core/rrb_vector/protocols.cljs to .cljs-test-runner/clojure/core/rrb_vector/protocols.cljs
Reading analysis cache for jar:file:/home/arichiardi/.m2/repository/org/clojure/clojurescript/1.10.339/clojurescript-1.10.339.jar!/cljs/core.cljs
Compiling .cljs-test-runner/clojure/core/rrb_vector/protocols.cljs to .cljs-test-runner/clojure/core/rrb_vector/protocols.js

I wonder what it is going wrong, the classpath is built correctly. It might be something very silly on my end and the runner works in other projects with aliases.

point the test runner to a file of compiled js?

Hi, I have various builds which compile the same bit of code, but with various build setups... shadow, bundle & etc. All these builds output a single file, so what I'd like is to be able to have the test runner just execute these files somehow and report.

Perhaps the requirement would be that the main ns needs to contains tests, or just requires test namespaces?

Disable verbose mode

Hi again ๐Ÿ˜„

I feel the compilation logs should not be there, or at least should be configurable. So I wonder if a tweak like :verbose false could be an option.

Thanks for your work by the way!

Default --dir value is wrongly showing up

It seems like the default value of --dir is mistakenly added even if one specifies it explicitly.

Example, I have:

 clojure -Srepro -A:test-cljs -m cljs-test-runner.main --dir test/cljs --out .cljs/ --namespace-regex 'sieppari.*-test$' --env node --watch src --watch test/cljs

Some debugging in accumulate reveals:

|||| {:dir #{test}, :out cljs-test-runner-out, :env :node} :dir test/cljs
|||| {:dir #{test/cljs test}, :out .cljs/, :env :node} :ns-regexs #"sieppari.*-test$"

The project does not have test, only test/cljs so this fails.

I am already kind of debugging so I should be able to provide a patch for this.

namespaces undetected

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]]}

Watcher CompilerException

Hi again,
I have found another small issue with the --watch flag. The first time around, in my code base, everything is good. The second reload is throwing the following:

#error {
 :cause Could not locate goog/object__init.class or goog/object.clj on classpath.
 :via
 [{:type clojure.lang.Compiler$CompilerException
   :message java.io.FileNotFoundException: Could not locate goog/object__init.class or goog/object.clj on classpath., compiling:(shared/async_test.cljc:1:1)
   :at [clojure.lang.Compiler load Compiler.java 7533]}
  {:type java.io.FileNotFoundException
   :message Could not locate goog/object__init.class or goog/object.clj on classpath.
   :at [clojure.lang.RT load RT.java 463]}]
 :trace
 [[clojure.lang.RT load RT.java 463]
  [clojure.lang.RT load RT.java 426]
  [clojure.core$load$fn__6629 invoke core.clj 6061]
  [clojure.core$load invokeStatic core.clj 6060]
  [clojure.core$load doInvoke core.clj 6044]
  [clojure.lang.RestFn invoke RestFn.java 408]
  [clojure.core$load_one invokeStatic core.clj 5863]
  [clojure.core$load_one invoke core.clj 5858]
  [clojure.core$load_lib$fn__6574 invoke core.clj 5903]
  [clojure.core$load_lib invokeStatic core.clj 5902]
  [clojure.core$load_lib doInvoke core.clj 5883]
  [clojure.lang.RestFn applyTo RestFn.java 142]
  [clojure.core$apply invokeStatic core.clj 659]
  [clojure.core$load_libs invokeStatic core.clj 5940]
  [clojure.core$load_libs doInvoke core.clj 5924]
  [clojure.lang.RestFn applyTo RestFn.java 137]
  [clojure.core$apply invokeStatic core.clj 659]
  [clojure.core$require invokeStatic core.clj 5962]
  [clojure.core$require doInvoke core.clj 5962]
  [clojure.lang.RestFn invoke RestFn.java 551]
  [shared.async_test$eval3857$loading__6515__auto____3858 invoke async_test.cljc 1]
  [shared.async_test$eval3857 invokeStatic async_test.cljc 1]
  [shared.async_test$eval3857 invoke async_test.cljc 1]
  [clojure.lang.Compiler eval Compiler.java 7069]
  [clojure.lang.Compiler eval Compiler.java 7058]
  [clojure.lang.Compiler load Compiler.java 7521]
  [clojure.lang.RT loadResourceScript RT.java 379]
  [clojure.lang.RT loadResourceScript RT.java 370]
  [clojure.lang.RT load RT.java 460]
  [clojure.lang.RT load RT.java 426]
  [clojure.core$load$fn__6629 invoke core.clj 6061]
  [clojure.core$load invokeStatic core.clj 6060]
  [clojure.core$load doInvoke core.clj 6044]
  [clojure.lang.RestFn invoke RestFn.java 408]
  [clojure.core$load_one invokeStatic core.clj 5863]
  [clojure.core$load_one invoke core.clj 5858]
  [clojure.core$load_lib$fn__6574 invoke core.clj 5903]
  [clojure.core$load_lib invokeStatic core.clj 5902]
  [clojure.core$load_lib doInvoke core.clj 5883]
  [clojure.lang.RestFn applyTo RestFn.java 142]
  [clojure.core$apply invokeStatic core.clj 659]
  [clojure.core$load_libs invokeStatic core.clj 5940]
  [clojure.core$load_libs doInvoke core.clj 5924]
  [clojure.lang.RestFn applyTo RestFn.java 137]
  [clojure.core$apply invokeStatic core.clj 659]
  [clojure.core$require invokeStatic core.clj 5962]
  [clojure.core$require doInvoke core.clj 5962]
  [clojure.lang.RestFn invoke RestFn.java 421]
  [cljs.closure$watch invokeStatic closure.clj 3113]
  [cljs.closure$watch invoke closure.clj 3021]
  [cljs.build.api$watch invokeStatic api.clj 222]
  [cljs.build.api$watch invoke api.clj 210]
  [cljs.build.api$watch invokeStatic api.clj 219]
  [cljs.build.api$watch invoke api.clj 210]
  [cljs.build.api$watch invokeStatic api.clj 213]
  [cljs.build.api$watch invoke api.clj 210]
  [cljs_test_runner.main$test_cljs_namespaces_in_dir invokeStatic main.clj 137]
  [cljs_test_runner.main$test_cljs_namespaces_in_dir invoke main.clj 105]
  [cljs_test_runner.main$_main invokeStatic main.clj 201]
  [cljs_test_runner.main$_main doInvoke main.clj 194]
  [clojure.lang.RestFn applyTo RestFn.java 137]
  [clojure.lang.Var applyTo Var.java 702]
  [clojure.core$apply invokeStatic core.clj 657]
  [clojure.main$main_opt invokeStatic main.clj 317]
  [clojure.main$main_opt invoke main.clj 313]
  [clojure.main$main invokeStatic main.clj 424]
  [clojure.main$main doInvoke main.clj 387]
  [clojure.lang.RestFn applyTo RestFn.java 137]
  [clojure.lang.Var applyTo Var.java 702]
  [clojure.main main main.java 37]]}

My test looks like:

(ns shared.async-test
  (:require [clojure.core.async :as async :refer-macros [go] :refer [<! >!]]
            [cljs.spec.test.alpha :as stest]
            [cljs.test :as test :refer-macros [deftest is testing]]
            [goog.object :as gobj]
            [shared.async :as shared-async]
            ))

(defn throwing-ch []
  (let [ch (async/chan)]
    (js/setTimeout (fn []
                     ;; triggering a runtime error
                     (async/put! ch (gobj/get (js* "undefined") :foo)))
                   100)
    ch))

...

I wonder what can be the cause there, I am going to investigate a bit.

EDIT1: This does not happen with something like shadow-cljs - data point
EDIT2: Code in the test does not really matter it seems...the exception changes but it is still thrown the second time around

Possible to use cljs-test-runner on core.rrb-vector library?

I have made some changes to a local copy of the core.rrb-vector library, in particular the ClojureScript implementation of it, and tried using cljs-test-runner to run some tests that I have locally changed to attempt to use clojure.test deftest/is/are/etc.

When I tried to run the tests using cljs-test-runner, it kept failing to compiler an older version of one of the core.rrb-vector source files. After scratching my head wondering how that could happen, since the old version wasn't in my source tree, I realized that doo depends upon fipp, which uses core.rrb-vector version 0.0.11.

Is this simply an issue of conflicting dependency versions, and I shouldn't be trying to use cljs-test-runner for running core.rrb-vector library tests?

support watch-option

Something like:

# watches the `--src` folder
$ clojure -Atest --watch

# additional folders:
$ clojure -Atest --watch src

Would you be interested in a PR for this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.