Skip to content

Commit a350d44

Browse files
committed
workaround for slashes in name/classname
1 parent 1fb133d commit a350d44

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

src/practitest_firecracker/const.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(ns practitest-firecracker.const)
22

3-
(def ^:const fc-version "2.1.2")
3+
(def ^:const fc-version "2.1.4")
44

55
(def ^:const testset-instances-uri "/projects/%d/instances.json")
66
(def ^:const test-uri "/projects/%d/tests/%d.json")

src/practitest_firecracker/parser/core.clj

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
[clojure.string :as str]
55
[clojure.xml :as xml]
66
[clojure.zip :as zip])
7-
(:import (java.text NumberFormat)
8-
(java.io ByteArrayInputStream)))
7+
(:import
8+
(java.io ByteArrayInputStream)
9+
(java.text NumberFormat)))
910

1011
(defn round
1112
[x & {p :precision}]
@@ -51,10 +52,27 @@
5152
{:tag :testsuites :content (flatten-testsuite root)}
5253
root))
5354

55+
(defn normalize-attribute [value]
56+
(when value
57+
(str/replace value "/" ".")))
58+
59+
(defn normalize-attributes
60+
"Sometimes `classname` and `name` contain '/', we need to replace it with '.'"
61+
[element]
62+
(if (map? element)
63+
(if-let [_attrs (:attrs element)]
64+
(-> element
65+
(update-in [:attrs :name] normalize-attribute)
66+
(update-in [:attrs :classname] normalize-attribute)
67+
(update :content #(map normalize-attributes %)))
68+
(update element :content #(map normalize-attributes %)))
69+
element))
70+
5471
(defn zip-str [s]
5572
(zip/xml-zip
56-
(preprocess-xunit
57-
(xml/parse (ByteArrayInputStream. (.getBytes s "UTF-8"))))))
73+
(normalize-attributes
74+
(preprocess-xunit
75+
(xml/parse (ByteArrayInputStream. (.getBytes s "UTF-8")))))))
5876

5977
(defn filter-tags [tag-key xml-content]
6078
(let [filter-result (filter #(= (:tag %) tag-key) xml-content)]
@@ -243,4 +261,9 @@
243261
(preprocess-xunit
244262
(xml/parse (ByteArrayInputStream. (.getBytes s "UTF-8"))))))
245263

264+
(let [s (slurp "test-data/pb/report.xml")]
265+
(normalize-attributes
266+
(preprocess-xunit
267+
(xml/parse (ByteArrayInputStream. (.getBytes s "UTF-8"))))))
268+
246269
)

0 commit comments

Comments
 (0)