|
73 | 73 | "Builds a test descriptor meeting the selector's criteria.")) |
74 | 74 |
|
75 | 75 | (extend-protocol Selector |
76 | | - nil |
77 | | - (-select [_] |
78 | | - nil) |
79 | | - Object |
80 | | - (-select [_] |
81 | | - nil) |
82 | | - |
83 | 76 | UniqueIdSelector |
84 | 77 | (-select [this] |
85 | 78 | (let [{:keys [namespace name]} (id->map (.getUniqueId this))] |
|
93 | 86 | (when (or (string/ends-with? path ".clj") |
94 | 87 | (string/ends-with? path ".cljc")) |
95 | 88 | (select-new-vars source (fn [] (load-file path)))))) |
96 | | - DirectorySelector |
97 | | - (-select [this] |
98 | | - ;; TODO implement |
99 | | - nil) |
100 | 89 |
|
101 | 90 | ClasspathResourceSelector |
102 | 91 | (-select [this] |
|
114 | 103 | ns-sym (symbol ns-name) |
115 | 104 | source (ClassSource/from name)] |
116 | 105 | (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))))))) |
122 | 107 |
|
123 | 108 | (defn select [^EngineDiscoveryRequest request ^UniqueId id] |
124 | 109 | (binding [*all-vars* (atom (all-vars))] |
|
127 | 112 | (loop [result [] |
128 | 113 | head (first selectors) |
129 | 114 | 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))))))) |
151 | 125 |
|
152 | 126 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
153 | 127 | ;; Discovery Descriptor Support |
|
169 | 143 | (.addChild ns-desc var-desc)) |
170 | 144 | ns-desc)) |
171 | 145 |
|
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)) |
174 | 148 | ns-descs (->> candidates |
175 | 149 | (group-by (comp namespace :sym)) |
176 | 150 | (map #(ns->descriptor id %)))] |
|
0 commit comments