Skip to content

Commit

Permalink
Make classpath-namespaces resilient to faulty ns decl, fixes clojure-…
Browse files Browse the repository at this point in the history
  • Loading branch information
mk committed May 9, 2022
1 parent c0e24f7 commit 6d6b717
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/orchard/namespace.clj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
(cond
(#{::eof ::fail} found) nil
(and (list? found)
(-> found first #{`ns 'ns}))
(-> found first #{`ns 'ns})
(symbol? (second found)))
(second found)
:else (recur))))))

Expand Down
3 changes: 3 additions & 0 deletions test/orchard/namespace_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
(testing "when multiple ns forms are present"
(spit url "(ns ns1) (ns ns2) (ns ns3)")
(is (= 'ns1 (sut/read-namespace uri))))
(testing "when ns form is invalid"
(spit url "(ns (:require [clojure.string]))")
(is (nil? (sut/read-namespace uri))))
(testing "of top-level forms only"
(spit url "(comment (ns ns1)) (ns ns2) (ns ns3)")
(is (= 'ns2 (sut/read-namespace uri))))
Expand Down

0 comments on commit 6d6b717

Please sign in to comment.