Skip to content

Commit a6fe9bd

Browse files
committed
fix test
1 parent 6bb4e03 commit a6fe9bd

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/nextjournal/clerk/analyzer.clj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@
100100

101101
(defn analyze-form [form]
102102
(with-bindings {clojure.lang.Compiler/LOADER (clojure.lang.RT/makeClassLoader)}
103-
(binding [ana/*deps* (or ana/*deps* (atom #{}))
104-
ana/*global-env* (ana/global-env)]
103+
(binding [ana/*deps* (or ana/*deps* (atom #{}))]
105104
(-> (analyze-form* (rewrite-defcached form))
106105
(ana/resolve-syms-pass)))))
107106

src/nextjournal/clerk/analyzer/impl.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,8 @@
465465
(:macro (meta maybe-macro)))
466466
(do
467467
(swap! *deps* conj maybe-macro)
468-
(analyze* env (macroexpand-hook maybe-macro form env (rest form))))
468+
(let [expanded (macroexpand-hook maybe-macro form env (rest form))]
469+
(analyze* env expanded)))
469470
{:op :invoke
470471
:form form
471472
:env env

test/nextjournal/clerk/analyzer_test.clj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
[nextjournal.clerk.config :as config]
1212
[nextjournal.clerk.fixtures.dep-a]
1313
[nextjournal.clerk.fixtures.dep-b]
14+
[nextjournal.clerk.fixtures.issue-660-repro]
1415
[nextjournal.clerk.parser :as parser]
1516
[weavejester.dependency :as dep])
1617
(:import (clojure.lang ExceptionInfo)))
@@ -182,7 +183,11 @@
182183
(dissoc (ana/analyze '(nextjournal.clerk/defcached answer (do (Thread/sleep 4200) (inc 41)))) :form)))))
183184

184185
(testing "tools.analyzer AssertionError is rethrown as ExceptionInfo (#307)"
185-
(is (thrown? ExceptionInfo (ana/analyze '(def foo [] :bar))))))
186+
(is (thrown? ExceptionInfo (ana/analyze '(def foo [] :bar)))))
187+
188+
(testing "macro-expansion defining var occurs in deps"
189+
(with-ns-binding 'nextjournal.clerk.fixtures.issue-660-repro
190+
(= 2 (count (:deps (ana/analyze '(nextjournal.clerk.fixtures.macros/emit-nonsense))))))))
186191

187192
(deftest symbol->jar
188193
(is (ana/symbol->jar 'io.methvin.watcher.PathUtils))
@@ -403,7 +408,6 @@ my-uuid")]
403408
(-> specter-repro-analysis
404409
(assoc :record-missing-hash-fn (fn [report-entry] (swap! !missing-hash-store conj report-entry)))
405410
ana/hash)
406-
407411
(def missing-hash-report (first (deref !missing-hash-store)))
408412

409413
(is (= 'nextjournal.clerk.fixtures.issue-660-repro/nonsense

0 commit comments

Comments
 (0)