Skip to content

Commit c0f8eb8

Browse files
authored
CI: CLJS Node Test Runner (#61)
* add deps.edn test CLJS aliases * add build directory with cljs build configs - simple & advanced node builds * add test.yaml * add externs for process.on * update runner to catch the expected exceptions so tests complete under Node
1 parent 6ac8ed2 commit c0f8eb8

File tree

6 files changed

+47
-2
lines changed

6 files changed

+47
-2
lines changed

.github/workflows/test.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Tests
2+
on: [push]
3+
4+
jobs:
5+
# Runtime Tests
6+
runtime-test:
7+
name: Runtime Tests
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
12+
- uses: DeLaGuardo/[email protected]
13+
with:
14+
tools-deps: '1.10.1.763'
15+
16+
- name: Build tests
17+
run: clojure -M:cljs-test:adv
18+
19+
- name: Run tests
20+
run: |
21+
node out-adv-node/tests.js | tee test-out.txt
22+
grep -qxF '0 failures, 0 errors.' test-out.txt

build/node_adv.edn

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{:main cljs.core.async.test-runner
2+
:output-dir "out-adv-node"
3+
:output-to "out-adv-node/tests.js"
4+
:externs ["build/test_externs.js"]
5+
:optimizations :advanced
6+
:target :nodejs}

build/node_simple.edn

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{:main cljs.core.async.test-runner
2+
:output-dir "out-simp-node"
3+
:output-to "out-simp-node/tests.js"
4+
:optimizations :simple
5+
:static-fns true
6+
:pretty-print true
7+
:target :nodejs}

build/test_externs.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
process.on = function(){};

deps.edn

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
{org.clojure/tools.analyzer.jvm {:mvn/version "1.2.2"}}
44
:aliases
55
{:cljs-test {:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.597"}}
6-
:extra-paths ["src/test/cljs"]}
6+
:extra-paths ["src/main/clojure/cljs" "src/test/cljs"]}
7+
:adv {:main-opts ["-m" "cljs.main" "-v" "-co" "build/node_adv.edn" "-c"]}
8+
:simp {:main-opts ["-m" "cljs.main" "-v" "-co" "build/node_simple.edn" "-c"]}
79

810
;; For compile test purposes
911
;; clj -T:build compile

src/test/cljs/cljs/core/async/test_runner.cljs

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@
1313
[cljs.core.async.timers-test]
1414
[cljs.core.async.interop-tests]
1515
[cljs.core.async.tests]
16-
[cljs.core.async.runner-tests]))
16+
[cljs.core.async.runner-tests]
17+
[clojure.string :as string]))
18+
19+
(when (exists? js/process)
20+
(.on js/process "uncaughtException"
21+
(fn [e]
22+
(when-not (= "Assert failed: This exception is expected\nfalse" (.-message e))
23+
(println "TESTS FAILED TO COMPLETE:" (.-message e))))))
1724

1825
(run-tests
1926
'cljs.core.async.runner-tests

0 commit comments

Comments
 (0)