Skip to content

Commit 6e01b14

Browse files
mfikesswannodette
authored andcommitted
CLJS-3043: error__GT_str not defined for cli scripts
1 parent 950032d commit 6e01b14

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

src/main/clojure/cljs/cli.clj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,9 @@ present"
354354
(fn []
355355
(try
356356
(repl/setup renv repl/*repl-opts*)
357+
;; Load cljs.repl runtime (so ex-str, ex-triage, etc. are available)
358+
(repl/evaluate-form renv (ana-api/empty-env) "<cljs repl>"
359+
`(~'require ~''cljs.repl))
357360
;; REPLs don't normally load cljs_deps.js
358361
(when (and coptsf (.exists coptsf))
359362
(let [depsf (io/file (:output-dir opts) "cljs_deps.js")]

src/test/cljs_cli/cljs_cli/test.clj

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[clojure.java.io :as io]
55
[clojure.java.shell :as shell :refer [with-sh-dir]]
66
[clojure.string :as str]
7-
[cljs-cli.util :refer [cljs-main output-is with-sources with-in with-post-condition with-repl-env-filter repl-title]]
7+
[cljs-cli.util :refer [cljs-main output-is check-result with-sources with-in with-post-condition with-repl-env-filter repl-title]]
88
[clojure.string :as string]))
99

1010
(deftest eval-test
@@ -127,3 +127,21 @@
127127
(with-repl-env-filter #{"graaljs"}
128128
(-> (cljs-main "-e" "(.eval js/Polyglot \"js\" \"1+1\")")
129129
(output-is 2))))
130+
131+
(deftest test-cljs-3043
132+
(with-repl-env-filter (complement #{"rhino"})
133+
(let [check-fn (fn [result]
134+
(is (= 1 (:exit result)))
135+
(is (str/includes? (:err result) "Execution error"))
136+
(is (not (str/includes? (:err result) "error__GT_str"))))]
137+
(-> (cljs-main
138+
"-e" "js/foo")
139+
(check-result check-fn))
140+
(with-sources {"src/foo/core.cljs"
141+
"(ns foo.core) (prn js/bogus)"}
142+
(-> (cljs-main "-m" "foo.core")
143+
(check-result check-fn)))
144+
(with-sources {"src/foo/core.cljs"
145+
"(ns foo.core) (prn js/bogus)"}
146+
(-> (cljs-main "src/foo/core.cljs")
147+
(check-result check-fn))))))

src/test/cljs_cli/cljs_cli/util.clj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,9 @@
102102
(is (= (string/trim (apply str (map print-str (interleave expected-lines (repeat "\n")))))
103103
(string/trim (:out result))))))
104104

105+
(defn check-result [result pred]
106+
(when-not (:repl-env-filtered result)
107+
(pred result)))
108+
105109
(defn repl-title []
106110
(string/trim (with-out-str (repl/repl-title))))

0 commit comments

Comments
 (0)