ClojureScript

Running the Tests

Testing the Compiler Infrastructure

lein test

Will run the tests for the analyzer, compiler, and closure components.

Testing JavaScript Engines

How to setup the important JavaScript runtimes.

Google V8

Set the V8_HOME environment variable to the path where d8 was built, for example:

export V8_HOME="$HOME/v8/out/x64.release"

Verify via:

echo quit | $V8_HOME/d8

Mozilla SpiderMonkey

Get the JavaScript shell (jsshell) from https://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-mozilla-central/. Set your SPIDERMONKEY_HOME environment variable to installation location.

Verify via:

$SPIDERMONKEY_HOME/js --version

WebKit JavaScriptCore

On macOS we test with JavaScriptCore. JavaScriptCore (jsc) should be on your system, but needs to be added to your PATH environment variable so that it will be found, for example:

export PATH="$PATH:/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources"

Verify that jsc brings up a prompt.

Java Nashorn

Setup the $NASHORN_HOME environment variable so that

$NASHORN_HOME/jjs

prompts a JavaScript Console. Nashorn is usually under $JAVA_HOME/bin, so you can write:

export NASHORN_HOME="$JAVA_HOME/bin"

Verify via:

echo 'quit()' | $NASHORN_HOME/jjs -fv

Oracle GraalVM

Get GraalVM from https://www.graalvm.org. Set your GRAALVM_HOME environment variable so that $GRAALVM_HOME/js executes Graal.js.

Verify via:

$GRAALVM_HOME/js --version

Microsoft ChakraCore

Get ChakraCore from https://github.com/Microsoft/ChakraCore/releases. Set your CHAKRACORE_HOME environment variable so that $CHAKRACORE_HOME/ch executes ChakraCore.

Verify via:

$CHAKRACORE_HOME/ch -version

Setting up dependencies

./script/bootstrap

Running the tests

./script/test

Will run tests for each JavaScript runtime that you setup as described above, runtimes that you did not setup will be skipped.

Running bootstrapped ClojureScript tests

If you have Node.js installed, you can run the bootstrapped ClojureScript test suite (located at src/test/self/self_host/test.cljs):

./script/test-self-host

You can also build and run the ClojureScript compiler test suite in bootstrapped mode within Node.js by running

./script/test-self-parity

Running ClojureScript CLI (cljs.main) tests

You can run tests exercising the ClojureScript CLI by running

./script/test-cli repl-env [repl-env-opts-edn]

where repl-env is any of the built-in REPL environments (node, browser, etc.). This will be passed to cljs.main 's -re option.

Note that testing with graaljs REPL environment requires GRAALVM_HOME to be found early in your PATH. You can test via:

(export PATH="$GRAALVM_HOME:$PATH"; ./script/test-cli graaljs)

You can also specify a non-built-in REPL environment, but you would have to revise script/test-cli to include the downstream REPL environment on the classpath. You can also pass optional repl-env-opts-edn, which will be passed to cljs.main 's -ro option.

Don’t forget the Browser REPL

It is important to make sure that the Browser REPL hasn’t accidentally been broken.

You may have already run tests against the browser REPL via ./script/test-cli browser. If not, now is a good time to do so. Note: It is normal for this test to launch plenty of browser windows/tabs.

In addition, you might only be comfortable after some manual verification - if only to try a sanity (js/alert "Hello CLJS!"):

  1. You can launch a browser REPL by running clj -M -m cljs.main from the clojurescript project root dir.

  2. Or from a new empty dir, create a deps.edn that points to your build of the ClojureScript compiler replacing 1.10.123 with your local version:

    {:deps {org.clojure/clojurescript {:mvn/version "1.10.123"}}}

    and then from this dir, run cljs -m cljs.main.