Skip to content

Commit

Permalink
Fix namespace filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahTheDuke committed Nov 19, 2024
1 parent baca398 commit 7a7a1d6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
8 changes: 4 additions & 4 deletions src/clojure/lazytest/filter.clj
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@
[ns-suite config]
(let [var-filter (map (comp symbol namespace) (:var-filter config))
ns-filter (not-empty (into #{} (concat var-filter (:ns-filter config))))]
(when (and ns-filter
(ns-filter (:doc ns-suite)))
(filter-suite ns-suite config))
(filter-suite ns-suite config)))
(if ns-filter
(when (ns-filter (:doc ns-suite))
(filter-suite ns-suite config))
(filter-suite ns-suite config))))

(defmethod filter-tree :lazytest/run
filter-tree--lazytest-run
Expand Down
21 changes: 7 additions & 14 deletions src/clojure/lazytest/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
(:gen-class)
(:require
[clojure.java.io :as io]
[clojure.set :as set]
[clojure.tools.namespace.file :refer [read-file-ns-decl]]
[clojure.tools.namespace.find :refer [find-sources-in-dir]]
[lazytest.cli :refer [validate-opts]]
Expand All @@ -13,18 +12,12 @@
[lazytest.runner :refer [run-tests]]
[lazytest.watch :as watch]))

(defn find-ns-decls [config dirs]
(let [var-filter-nses (->> (:var-filter config)
(map (comp symbol namespace))
(into #{}))
ns-filter (or (not-empty (set/union (:ns-filter config) var-filter-nses))
any?)]
(into []
(comp (mapcat find-sources-in-dir)
(keep read-file-ns-decl)
(keep second)
(filter ns-filter))
dirs)))
(defn find-ns-decls [dirs]
(into []
(comp (mapcat find-sources-in-dir)
(keep read-file-ns-decl)
(keep second))
dirs))

(defn add-md-tests
[config dirs]
Expand All @@ -39,7 +32,7 @@
(defn require-dirs [config dir]
(let [dirs (map io/file (or dir #{"test"}))
md-nses (add-md-tests config dirs)
nses (into (find-ns-decls config dirs)
nses (into (find-ns-decls dirs)
md-nses)]
(when (empty? nses)
(throw (ex-info "No namespaces to run" {:dir dir})))
Expand Down
3 changes: 1 addition & 2 deletions test/clojure/lazytest/find_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
(vreset! output (with-out-str-data-map
(main/run ["--dir" "corpus/find_tests"
"--output" "nested*"]))))
(after (remove-ns 'find-tests.examples)
(vreset! output nil))]}
(after (vreset! output nil))]}
(it "runs all suites"
(expect
(match?
Expand Down

0 comments on commit 7a7a1d6

Please sign in to comment.