Skip to content
This repository was archived by the owner on Nov 6, 2025. It is now read-only.

Commit bcba734

Browse files
committed
More fixes
1 parent 131e64b commit bcba734

File tree

1 file changed

+13
-39
lines changed

1 file changed

+13
-39
lines changed

src/main/clojure/org/ajoberstar/jovial/engine.clj

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,6 @@
7373
"Builds a test descriptor meeting the selector's criteria."))
7474

7575
(extend-protocol Selector
76-
nil
77-
(-select [_]
78-
nil)
79-
Object
80-
(-select [_]
81-
nil)
82-
8376
UniqueIdSelector
8477
(-select [this]
8578
(let [{:keys [namespace name]} (id->map (.getUniqueId this))]
@@ -93,10 +86,6 @@
9386
(when (or (string/ends-with? path ".clj")
9487
(string/ends-with? path ".cljc"))
9588
(select-new-vars source (fn [] (load-file path))))))
96-
DirectorySelector
97-
(-select [this]
98-
;; TODO implement
99-
nil)
10089

10190
ClasspathResourceSelector
10291
(-select [this]
@@ -114,11 +103,7 @@
114103
ns-sym (symbol ns-name)
115104
source (ClassSource/from name)]
116105
(when (string/ends-with? name "__init")
117-
(select-new-vars source (fn [] (require ns-sym))))))
118-
ClasspathRootSelector
119-
(-select [this]
120-
;; TODO implement
121-
nil))
106+
(select-new-vars source (fn [] (require ns-sym)))))))
122107

123108
(defn select [^EngineDiscoveryRequest request ^UniqueId id]
124109
(binding [*all-vars* (atom (all-vars))]
@@ -127,27 +112,16 @@
127112
(loop [result []
128113
head (first selectors)
129114
tail (rest selectors)]
130-
(let [candidates (try
131-
(-select head)
132-
(catch Exception e
133-
(.selectorProcessed listener id head (SelectorResolutionResult/failed e))
134-
:failed))]
135-
;; notify listener of result
136-
(cond
137-
(= :failed candidates)
138-
nil
139-
140-
(some? candidates)
141-
142-
(.selectorProcessed listener id head (SelectorResolutionResult/resolved))
143-
144-
:else
145-
(.selectorProcessed listener id head (SelectorResolutionResult/unresolved)))
146-
147-
;; continue with remaining selectors
148-
(if tail
149-
(recur (concat result candidates) (first tail) (rest tail))
150-
(concat result candidates)))))))
115+
(if (satisfies? Selector head)
116+
(let [candidates (try
117+
(-select head)
118+
(.selectorProcessed listener id head (SelectorResolutionResult/resolved))
119+
(catch Exception e
120+
(.selectorProcessed listener id head (SelectorResolutionResult/failed e))))]
121+
(if tail
122+
(recur (concat result candidates) (first tail) (rest tail))
123+
(concat result candidates)))
124+
(.selectorProcessed listener id head (SelectorResolutionResult/unresolved)))))))
151125

152126
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
153127
;; Discovery Descriptor Support
@@ -169,8 +143,8 @@
169143
(.addChild ns-desc var-desc))
170144
ns-desc))
171145

172-
(defn selections->descriptor [engine ^UniqueId id candidates]
173-
(let [engine-desc (EngineDescriptor. id (id engine))
146+
(defn selections->descriptor [engine ^UniqueId root-id candidates]
147+
(let [engine-desc (EngineDescriptor. root-id (id engine))
174148
ns-descs (->> candidates
175149
(group-by (comp namespace :sym))
176150
(map #(ns->descriptor id %)))]

0 commit comments

Comments
 (0)