Skip to content

Commit c7aca4b

Browse files
author
dnolen
committed
make it possible to run self-host tests at command line
1 parent 0666699 commit c7aca4b

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

script/test-self-host

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
# stop blowing compiled stuff
4+
rm -rf builds/out-self
5+
mkdir -p builds/out-self
6+
7+
bin/cljsc src/test/cljs/self_host "{:optimizations :simple :static-fns true :output-dir \"builds/out-self\" :optimize-constants true :verbose true :compiler-stats true :target :nodejs}" > builds/out-self/core-self-test.js
8+
9+
echo "Testing with Node"
10+
node builds/out-self/core-self-test.js

src/test/cljs/self_host/test.cljs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
(ns self-host.test
22
(:require [cljs.test :as test
33
:refer-macros [run-tests deftest testing is async]]
4-
[cljs.js :as cljs]))
4+
[cljs.js :as cljs]
5+
[cljs.nodejs :as nodejs]))
6+
7+
(nodejs/enable-util-print!)
58

69
(defn latch [m f]
710
(let [r (atom 0)]
@@ -13,8 +16,6 @@
1316
(defn inc! [r]
1417
(swap! r inc))
1518

16-
(set! *target* "nodejs")
17-
1819
(def vm (js/require "vm"))
1920
(def fs (js/require "fs"))
2021
(def st (cljs/empty-state))
@@ -71,7 +72,7 @@
7172
(is (nil? error))
7273
(is (== value 2))
7374
(inc! l)))
74-
(cljs/eval-str st "(def x 1)" nil
75+
#_(cljs/eval-str st "(def x 1)" nil
7576
{:eval node-eval
7677
:context :expr
7778
:def-emits-var true}
@@ -86,4 +87,9 @@
8687
(fn [{:keys [error value]}]
8788
(is (nil? error))
8889
(is (fn? value))
89-
(inc! l))))))
90+
(inc! l))))))
91+
92+
(defn -main [& args]
93+
(run-tests))
94+
95+
(set! *main-cli-fn* -main)

0 commit comments

Comments
 (0)