Commit e50663e 1 parent a42b2c7 commit e50663e Copy full SHA for e50663e
File tree 1 file changed +20
-7
lines changed
1 file changed +20
-7
lines changed Original file line number Diff line number Diff line change 111
111
(catch Exception _))
112
112
transport))
113
113
114
+ (def ^:private ^:dynamic *test-report* nil )
115
+
116
+ (defmulti ^:dynamic report (constantly :default ))
117
+
118
+ (defmethod report :default [message]
119
+ (when *test-report*
120
+ (swap! *test-report* conj message))
121
+ (when-let [f (get-method report (:type message))]
122
+ (f message)))
123
+
124
+ (defn- add-method [^clojure.lang.MultiFn multifn dispatch-val f]
125
+ (.addMethod multifn dispatch-val f))
126
+
127
+ (doseq [[dispatch-value f] (methods test/report)]
128
+ (add-method report dispatch-value f))
129
+
114
130
(defn- wrap-portal* [handler msg]
115
- (let [report (atom [])
116
- test-report test/report
117
- portal-report (fn [value]
118
- (swap! report conj value)
119
- (test-report value))]
131
+ (let [test-report (atom [])]
120
132
(handler
121
133
(cond-> msg
122
134
(#{" eval" " load-file" } (:op msg))
123
135
(-> (update :transport
124
136
->PortalTransport
125
137
(assoc msg
126
- :report report
138
+ :report test- report
127
139
:stdio (atom [])
128
140
:start (System/nanoTime )
129
141
:time (Date. )))
130
142
(update :session
131
143
(fn [session]
132
144
(swap! session assoc
133
- #'test/report portal-report)
145
+ #'test/report report
146
+ #'*test-report* test-report)
134
147
session)))))))
135
148
136
149
(defn wrap-portal
You can’t perform that action at this time.
0 commit comments