There are various test suites under src/test
- cljs
- cljs_cli
- clojure
- self
Also under src/test are ClojureScript files that are used as compiler inputs for tests:
- cljs_build
- cljs_cp
- externs
- node
There are a handful of `script/test-…` scripts to invoke these different tests. Other helper scripts used are
- ci/install_jsc.sh – install Webkit jsc executable
- script/cljc – wrapper script to invoke the clojurescript compiler with specific inputs and compiler options
Found in src/test/cljs, typically run by doing an advanced compilation
outputting to builds/out-adv/core-advanced-test.js, and then passing it to
some command line JS runner like jsc.
Can be run with script/test, this will use script/cljc to create an advanced
build, then run it with any JS runtime it can find. It looks for jsc on the
$PATH, for other runtimes it relies on specific environment variables like
SPIDERMONKEY_HOME, V8_HOME etc. See the section on JS Runtimes below.
If you want to just compile the tests so you can run them yourself with one or
more JS runtimes (jsc, d8, jjs, ch, etc), then use clj
-A:runtime.test.build. This uses compiler options found in
resources/test.edn, and outputs builds/out-adv/core-advanced-test.js.
Tests that invoke cljs.main with various arguments. These are written in
Clojure, there’s a minimal test runner that invokes clojure.test in
cljs-cli.test-runner.
Can be run with clj -A:cli.test.run or script/test-cli
You can pass the name of a repl-env to script/test-cli, e.g. script/test-cli node.
clojure.test based tests, found under src/test/clojure, that invoke the analyzer, compiler, etc.
Runner in clj.test-runner, can be invoked with clj -A:compiler.test:compiler.test.run
Two separate test suites, really. self-host and self-parity. Can be run with
script/test-self-host and script/test-self-parity.
self-host: tests under src/test/self/self_host, see compiler options in
resources/self_host_test.edn. After compilation can be run with node.
self-parity: tests under src/test/self/self_parity, see compiler options in
resources/self_parity_test.edn. After compilation can be run with node.
In .travis.yml and .github/workflows/test.yml you can see how things are run
on CI. The travis one in particular shows how you can fetch Spidermonkey,
javascript-core, chakra-core, graalvm to test on multiple js environments.
These are the runtimes that `script/test` looks for. Also showing the environment variables that `script/test` looks for to find the executables.
Use the jsc command line tool. On ubuntu you can grab
libjavascriptcoregtk-4.0-bin, or install from source with ci/install_jsc.sh
Use the jsshell command line tool.
wget https://ftp.mozilla.org/pub/firefox/nightly/latest-mozilla-central/jsshell-linux-x86_64.zip unzip jsshell-linux-x86_64.zip -d spidermoney export SPIDERMONKEY_HOME="$(pwd)/spidermonkey"
wget https://aka.ms/chakracore/cc_linux_x64_1_8_1 -O chakra-core.tar.gz
tar xvzf chakra-core.tar.gz
export CHAKRACORE_HOME="$(pwd)/ChakraCoreFiles/bin"wget https://github.com/oracle/graal/releases/download/vm-1.0.0-rc12/graalvm-ce-1.0.0-rc12-linux-amd64.tar.gz
tar xzf graalvm-ce-1.0.0-rc12-linux-amd64.tar.gz
export GRAALVM_HOME="$(pwd)/graalvm-ce-1.0.0-rc12"Requires the d8 executable. I can’t really find ready-made binaries, official
instructions show how to build from source.
export V8_HOME="/dir/where/d8/is/found"Probably the least important target to test against at this point.
export NASHORN_HOME="/dir/where/jjs/is/found"