Skip to content

Commit 1cc449d

Browse files
author
shmuelko
committed
get each instance failure message
1 parent 3c3f3cc commit 1cc449d

3 files changed

Lines changed: 53 additions & 36 deletions

File tree

deps.edn

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
throttler/throttler {:mvn/version "1.0.0"}
88
org.clojure/tools.logging {:mvn/version "1.1.0"}
99
ch.qos.logback/logback-classic {:mvn/version "1.2.3"}
10-
clj-time/clj-time {:mvn/version "0.15.2"}}
10+
clj-time/clj-time {:mvn/version "0.15.2"}
11+
vlaaad/reveal {:mvn/version "1.3.280"}}
1112

1213
:aliases
1314
{:dev {:extra-paths ["dev"]}
@@ -17,4 +18,7 @@
1718
:main-opts ["-m" "uberdeps.uberjar"]}
1819
:depstar {:extra-deps
1920
{seancorfield/depstar {:mvn/version "1.0.94"}}}
20-
:webassets {:extra-paths ["dev"]}}}
21+
:webassets {:extra-paths ["dev"]}
22+
:reveal {:extra-deps {vlaaad/reveal {:mvn/version "1.3.280"}}
23+
;; optional: preferences
24+
:jvm-opts ["-Dvlaaad.reveal.prefs={:theme,:light}"]}}}

src/practitest_firecracker/eval.clj

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,23 @@
107107

108108
(defn is-failed-step [only-failed-steps desc failure-detail]
109109
(or (not only-failed-steps)
110-
(and (not (nil? failure-detail)) (string/includes? failure-detail desc))))
111-
112-
(defn sf-test-case->run-step-def [options params test-case]
113-
(let [description (or (:description test-case) (sf-test-case->pt-step-description options test-case))
114-
new-desc (replace-map description (replace-keys params))]
110+
(and
111+
(not (nil? failure-detail))
112+
(not (nil? desc))
113+
(string/includes? failure-detail desc))))
114+
115+
(defn sf-test-case->run-step-def [options params test-suite-cases test-case]
116+
(let [grouped-case (group-by (fn [case] (sf-test-case->pt-step-description options case)) test-suite-cases)
117+
description (or (:description test-case) (sf-test-case->pt-step-description options test-case))
118+
new-desc (replace-map description (replace-keys params))
119+
origin-case (first (get grouped-case new-desc))
120+
msg (str (or (:failure-message origin-case) (:failure-message test-case)) \newline (:failure-detail test-case))]
115121
{:name (if (nil? (:position test-case))
116122
(sf-test-case->pt-step-name options test-case)
117123
(or (:pt-test-step-name test-case)
118124
(sf-test-case->pt-step-name options test-case)))
119125
:description new-desc
120-
:actual-results (when
121-
(is-failed-step
122-
(:only-failed-steps options)
123-
new-desc
124-
(str (:failure-message test-case) \newline (:failure-detail test-case)))
125-
(str (:failure-message test-case) \newline (:failure-detail test-case)))
126+
:actual-results (when (is-failed-step (:only-failed-steps options) new-desc msg) msg)
126127
:status (case (when (is-failed-step (:only-failed-steps options) new-desc (:failure-detail test-case)) (:failure-type test-case))
127128
:failure "FAILED"
128129
:skipped "N/A"
@@ -131,10 +132,10 @@
131132
nil "PASSED"
132133
"NO RUN")}))
133134

134-
(defn sf-test-suite->run-def [options test-suite params]
135-
[{:run-duration (:time-elapsed test-suite)}
136-
(map (partial sf-test-case->run-step-def options params)
137-
(sort-by :position (:test-cases test-suite)))])
135+
(defn sf-test-suite->run-def [options test-suite sys-test params]
136+
[{:run-duration (:time-elapsed sys-test)}
137+
(map (partial sf-test-case->run-step-def options params (:test-cases test-suite))
138+
(sort-by :position (:test-cases sys-test)))])
138139

139140
(defn sf-test-run->run-def [custom-fields run-duration]
140141
{:run-duration (:time-elapsed run-duration),

src/practitest_firecracker/practitest.clj

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@
4646
{}
4747
(distinct (into (keys map1) (keys map2)))))
4848

49-
(defn update-steps [use-test-step old-tests test-cases match-step-by options new-map]
50-
(if use-test-step
49+
(defn update-steps [old-tests test-id-to-cases test-name-to-params options]
50+
(if (:use-test-step options)
5151
(map
5252
(fn [t]
5353
(let [test-id (Integer/parseInt (:id (last t)))
5454
test-name (first t)
55-
params (get new-map test-name)
56-
test-test-cases (get test-cases test-id)
55+
params (get test-name-to-params test-name)
56+
test-test-cases (get test-id-to-cases test-id)
5757
t-test-cases (filter
5858
(fn [case]
5959
(not (and (:only-failed-steps options) (= "" (:failure-detail case)))))
@@ -67,7 +67,7 @@
6767
(reduce (fn [p param]
6868
(or p
6969
(replace-map
70-
(if (= match-step-by "description")
70+
(if (= (:match-step-by options) "description")
7171
(:description case)
7272
(:pt-test-step-name case))
7373
(replace-keys param))))
@@ -77,7 +77,7 @@
7777
(reduce (fn [p param]
7878
(or p
7979
(replace-map
80-
(if (= match-step-by "description")
80+
(if (= (:match-step-by options) "description")
8181
(eval/sf-test-case->pt-step-description options case)
8282
(eval/sf-test-case->pt-step-name options case))
8383
(replace-keys param))))
@@ -160,7 +160,7 @@
160160

161161
(defn create-instances [[all-tests org-xml-tests testset-id-to-name ts-id-test-name-num-instances test-id-to-cases tests-after]
162162
client
163-
{:keys [project-id display-action-logs display-run-time pt-instance-params use-test-step match-step-by] :as options} start-time]
163+
{:keys [project-id display-action-logs display-run-time pt-instance-params] :as options} start-time]
164164
(when display-action-logs (log/infof "pt-instance-params: %s" pt-instance-params))
165165
(let [all-test-ids (map (fn [test] (:id (last test))) all-tests)
166166
testname-test (into {} (map (fn [test] {(first test) test}) all-tests))
@@ -203,7 +203,7 @@
203203
#(eval/sf-test-suite->pt-test-name options %)
204204
org-xml-tests))))
205205

206-
testname-test2 (when
206+
test-name-param-vals (when
207207
(not-empty pt-instance-params)
208208
(into
209209
#{}
@@ -223,7 +223,7 @@
223223
test-type (:test-type (:attributes (last obj-test)))
224224
params (if (= test-type "BDDTest") bdd-parameters parameters)
225225
vals (into [] (if (map? params) (vals params) params))]
226-
(contains? testname-test2 (str name ":" vals))))
226+
(contains? test-name-param-vals (str name ":" vals))))
227227
instances)
228228
instances)
229229

@@ -262,7 +262,7 @@
262262
(get-in inst [:attributes :name]))
263263
filter-instances))))
264264

265-
new-map (into {}
265+
test-name-to-params (into {}
266266
(map
267267
(fn [test-name]
268268
(reduce (fn [a b]
@@ -293,10 +293,13 @@
293293
(map
294294
(fn [test-name]
295295
{test-name
296-
(into [] (difference (set (get new-map test-name)) (set (get existing-instance test-name))))})
297-
(keys new-map)))
296+
(into []
297+
(difference
298+
(set (get test-name-to-params test-name))
299+
(set (get existing-instance test-name))))})
300+
(keys test-name-to-params)))
298301

299-
tests-with-steps (update-steps use-test-step all-tests test-id-to-cases match-step-by options new-map)
302+
tests-with-steps (update-steps all-tests test-id-to-cases test-name-to-params options)
300303
all-tests (concat tests-after tests-with-steps)
301304
make-instances (flatten (api/make-instances missing-instances new-testname-to-params test-id-testname))
302305
test-by-id (group-by (fn [test] (read-string (:id (last test)))) all-tests)
@@ -307,24 +310,33 @@
307310
filter-instances
308311
instances)))
309312

313+
group-xml-tests (group-by
314+
(fn [test]
315+
[(eval/sf-test-suite->pt-test-name options test)
316+
(when pt-instance-params (split-n-filter-instance-params test pt-instance-params))])
317+
org-xml-tests)
318+
310319
instance-to-ts-test (group-by (fn [inst] [(:set-id (:attributes inst)) (:test-id (:attributes inst))]) all-intstances)]
311320
(when display-run-time (print-run-time "Time - after create instances: %d:%d:%d" start-time))
312-
[test-by-id instance-to-ts-test new-map]))
321+
[test-by-id instance-to-ts-test test-name-to-params group-xml-tests]))
313322

314-
(defn make-runs [[test-by-id instance-to-ts-test new-map] client {:keys [project-id display-action-logs] :as options} start-time]
323+
(defn make-runs [[test-by-id instance-to-ts-test test-name-to-params group-xml-tests] client {:keys [display-action-logs] :as options} start-time]
315324
(when display-action-logs (log/infof "make-runs"))
316325
(flatten (doall
317326
(for [[test-testset instances] instance-to-ts-test]
318327
(map-indexed
319328
(fn [index instance]
320-
(let [[ts-id test-id] test-testset
329+
(let [[_ test-id] test-testset
321330
tst (first (get test-by-id test-id))
322-
params (get new-map (get tst 0))
331+
test-name (get tst 0)
332+
params (get test-name-to-params test-name)
323333
this-param (get params index)
324-
[run run-steps] (eval/sf-test-suite->run-def options (get tst 1) this-param)
334+
xml-test (get group-xml-tests [test-name (vals this-param)])
335+
sys-test (get tst 1)
336+
[run run-steps] (eval/sf-test-suite->run-def options (first xml-test) sys-test this-param)
325337
additional-run-fields (eval/eval-additional-fields run (:additional-run-fields options))
326338
additional-run-fields (merge additional-run-fields (:system-fields additional-run-fields))
327-
run (eval/sf-test-run->run-def additional-run-fields (get tst 1))]
339+
run (eval/sf-test-run->run-def additional-run-fields sys-test)]
328340
{:instance-id (:id instance)
329341
:attributes run
330342
:steps run-steps})) instances)))))

0 commit comments

Comments
 (0)