Skip to content

Commit 1dd32e1

Browse files
committed
tests work again
1 parent 9762639 commit 1dd32e1

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

src/nbb/impl/main.cljs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ Tooling:
132132
"))
133133

134134
(defn main []
135-
(let [[_ _ & args] process/argv
135+
(let [[_ _ & args] (or js/globalThis.nbb_args
136+
process/argv)
136137
opts (parse-args args)
137138
_ (reset! common/opts opts)
138139
script-file (:script opts)

test/nbb/main_test.cljs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
(ns nbb.main-test
22
(:require
3-
["module" :refer [createRequire]]
3+
["node:module" :refer [createRequire]]
44
["node:path" :as path]
5+
["node:process" :as process]
56
[clojure.string :as str]
67
[clojure.test :as t :refer [deftest is testing]]
78
[nbb.classpath :as cp]
@@ -18,13 +19,13 @@
1819
(def old-fail (get-method t/report [:cljs.test/default :fail]))
1920

2021
(defmethod t/report [:cljs.test/default :fail] [m]
21-
(set! js/process.exitCode 1)
22+
(set! process/exitCode 1)
2223
(old-fail m))
2324

2425
(def old-error (get-method t/report [:cljs.test/default :fail]))
2526

2627
(defmethod t/report [:cljs.test/default :error] [m]
27-
(set! js/process.exitCode 1)
28+
(set! process/exitCode 1)
2829
(old-error m))
2930

3031
(cp/add-classpath "test-scripts")
@@ -34,13 +35,13 @@
3435
;; See https://clojurescript.org/tools/testing#async-testing.
3536

3637
(defn with-args [args f]
37-
(let [old-args js/process.argv
38+
(let [old-args (or js/globalThis.nbb_args process/argv)
3839
args (into-array (list* nil nil args))]
39-
(set! (.-argv js/process) args)
40+
(set! js/globalThis.nbb_args args)
4041
(-> (f)
4142
(js/Promise.resolve)
4243
(.finally (fn []
43-
(set! (.-argv js/process) old-args))))))
44+
(set! js/globalThis.nbb_args old-args))))))
4445

4546
(defn main-with-args [args]
4647
(with-args args main/main))

0 commit comments

Comments
 (0)