Skip to content

Commit 176d541

Browse files
authored
Merge pull request #17 from Olical/advanced-optimisations
Fix test running with something other than :none optmisations
2 parents 0dec614 + 2daae08 commit 176d541

File tree

4 files changed

+40
-8
lines changed

4 files changed

+40
-8
lines changed

Diff for: README.md

+29-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,35 @@ $ clojure -Atest --help
7171
7272
## Gotchas
7373
74-
* 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.
74+
### Paths
75+
76+
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.
77+
78+
### Advanced compilation
79+
80+
This actually applies to everything other than `{:optimizations :none}` (which is the default). To use any Closure Compiler optimisation levels you will need to create an EDN file containing something like this:
81+
82+
```edn
83+
{:optimizations :advanced}
84+
```
85+
86+
The Closure compiler requires the generated test runner to be on the path so you'll need to add this to your `:paths` key in your `deps.edn`:
87+
88+
```edn
89+
:paths ["src" "test" "cljs-test-runner-out/gen"]
90+
```
91+
92+
It will fail the first time you run this, that's because that directory doesn't exist yet so it'll be removed from the path on startup. To fix this you can run the following before executing your tests:
93+
94+
```bash
95+
mkdir -p cljs-test-runner-out/gen
96+
```
97+
98+
Now when you run the following, your tests will be executed with advanced compilation:
99+
100+
```bash
101+
clj -m cljs-test-runner.main -c ./config/advanced-compilation.edn
102+
```
75103
76104
## Unlicenced
77105

Diff for: deps.edn

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{:paths ["src" "test" "other-tests"]
1+
{:paths ["src" "test" "other-tests" "cljs-test-runner-out/gen"]
22
:deps {org.clojure/clojure {:mvn/version "1.9.0"}
33
org.clojure/clojurescript {:mvn/version "1.10.339"}
44
org.clojure/tools.namespace {:mvn/version "0.3.0-alpha4"}

Diff for: src/cljs_test_runner/main.clj

+9-6
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@
5656
"Renders a ClojureScript test runner from a seq of namespaces."
5757
[nses {:keys [var include exclude]}]
5858
(str
59-
"(ns test.runner
60-
(:require [doo.runner :refer-macros [doo-tests]]"
61-
(str/join " " nses)"))"
59+
"(ns cljs-test-runner.gen
60+
(:require [doo.runner :refer-macros [doo-tests]] [" (str/join "] [" nses)"]))"
6261
ns-filter-cljs
6362
"(filter-vars! {" (str/join ", " (map #(str % " (ns-publics " (format-value %) ")") nses)) "}
6463
(var-filter {:var " (format-filter var) "
6564
:include " (format-filter include) "
6665
:exclude " (format-filter exclude) "}))"
66+
"\n"
6767
"(doo-tests " (str/join " " (map format-value nses)) ")"))
6868

6969
(defn ns-filter-fn
@@ -113,8 +113,8 @@
113113
:exclude exclude}))
114114
exit-code (atom 1)
115115
gen-path (str/join "/" [out "gen"])
116-
src-path (str/join "/" [gen-path "test-runner.cljs"])
117-
out-path (str/join "/" [out "test-runner.js"])
116+
src-path (str/join "/" [gen-path "cljs_test_runner" "gen.cljs"])
117+
out-path (str/join "/" [out "cljs_test_runner.gen.js"])
118118
{:keys [target doo-env]} (case env
119119
:node {:target :nodejs
120120
:doo-env :node}
@@ -126,7 +126,7 @@
126126
(let [build-opts (merge {:output-to out-path
127127
:output-dir out
128128
:target target
129-
:main 'test.runner
129+
:main "cljs-test-runner.gen"
130130
:optimizations :none
131131
:verbose verbose}
132132
compile-opts)
@@ -231,5 +231,8 @@
231231
;; doo-opts
232232
(run "-D" "test/doo-opts-test.edn")
233233

234+
;; cljs-opts
235+
(run "-c" "test/cljs-opts-test.edn")
236+
234237
;; help
235238
(run "-H"))

Diff for: test/cljs-opts-test.edn

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{:optimizations :advanced}

0 commit comments

Comments
 (0)