Skip to content

Commit bfe4811

Browse files
authored
Merge pull request #24 from PractiTest/PT1-40-fix-dsl-methods
PT1-40-fix-dsl-methods
2 parents c7d6a31 + 1cc449d commit bfe4811

6 files changed

Lines changed: 184 additions & 81 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/cli.clj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
(when (:additional-test-fields parsed-json) {:additional-test-fields new-additional-test-fields})
101101
(when (:additional-run-fields parsed-json) {:additional-run-fields new-additional-run-fields})
102102
(when (:pt-test-name parsed-json) {:pt-test-name (read-query (:pt-test-name parsed-json))})
103+
(when (:pt-test-step-description parsed-json) {:pt-test-step-description (read-query (:pt-test-step-description parsed-json))})
103104
(when (:pt-test-step-name parsed-json) {:pt-test-step-name (read-query (:pt-test-step-name parsed-json))}))]
104105
new-parsed-json))
105106

src/practitest_firecracker/eval.clj

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
(ns practitest-firecracker.eval
22
(:require
33
[clojure.string :as string]
4-
[practitest-firecracker.query-dsl :refer [query? eval-query]]
4+
[practitest-firecracker.query-dsl :refer [query? eval-query read-query]]
55
[clojure.walk :refer [postwalk]]
6-
[clojure.tools.logging :as log]
7-
[practitest-firecracker.utils :refer [pformat]]
8-
[practitest-firecracker.api :as api]))
6+
[practitest-firecracker.utils :refer [pformat replace-map replace-keys]]
7+
[practitest-firecracker.api :as api]
8+
[clojure.pprint :as pprint]))
99

1010
(def custom-field-cache (atom {}))
1111

@@ -17,12 +17,17 @@
1717
(let [test-name (eval-query suite (:pt-test-name options))]
1818
(if (string/blank? test-name) "UNNAMED" test-name)))
1919

20+
(defn sf-test-case->pt-step-description [options test-case]
21+
(let [step-name (eval-query test-case (:pt-test-step-description options))]
22+
(if (string/blank? step-name) "UNNAMED" step-name)))
23+
2024
(defn sf-test-case->pt-step-name [options test-case]
2125
(let [step-name (eval-query test-case (:pt-test-step-name options))]
2226
(if (string/blank? step-name) "UNNAMED" step-name)))
2327

2428
(defn sf-test-case->step-def [options test-case]
25-
{:name (sf-test-case->pt-step-name options test-case)})
29+
{:name (sf-test-case->pt-step-name options test-case)
30+
:description (sf-test-case->pt-step-description options test-case)})
2631

2732
(defn sf-test-suite->test-def [options test-suite]
2833
[{:name (sf-test-suite->pt-test-name options test-suite)}
@@ -100,21 +105,37 @@
100105
additional-testset-fields)
101106
(map :id tests))))
102107

103-
(defn sf-test-case->run-step-def [options test-case]
104-
{:name (sf-test-case->pt-step-name options test-case)
105-
:actual-results (str (:failure-message test-case) \newline (:failure-detail test-case))
106-
:status (case (:failure-type test-case)
107-
:failure "FAILED"
108-
:skipped "N/A"
109-
:error "FAILED"
110-
;; will leave error as FAILED for now, will change it after we add the UI changes and add the option of ERROR to Reqirement Test and TestSet table of runs
111-
nil "PASSED"
112-
"NO RUN")
113-
:description (:description test-case)})
114-
115-
(defn sf-test-suite->run-def [options test-suite]
116-
[{:run-duration (:time-elapsed test-suite)}
117-
(map (partial sf-test-case->run-step-def options) (:test-cases test-suite))])
108+
(defn is-failed-step [only-failed-steps desc failure-detail]
109+
(or (not only-failed-steps)
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))]
121+
{:name (if (nil? (:position test-case))
122+
(sf-test-case->pt-step-name options test-case)
123+
(or (:pt-test-step-name test-case)
124+
(sf-test-case->pt-step-name options test-case)))
125+
:description new-desc
126+
:actual-results (when (is-failed-step (:only-failed-steps options) new-desc msg) msg)
127+
:status (case (when (is-failed-step (:only-failed-steps options) new-desc (:failure-detail test-case)) (:failure-type test-case))
128+
:failure "FAILED"
129+
:skipped "N/A"
130+
:error "FAILED"
131+
;; will leave error as FAILED for now, will change it after we add the UI changes and add the option of ERROR to Reqirement Test and TestSet table of runs
132+
nil "PASSED"
133+
"NO RUN")}))
134+
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)))])
118139

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

0 commit comments

Comments
 (0)