Skip to content

Commit 7d3e761

Browse files
committed
Init report formatter
1 parent eb55bf9 commit 7d3e761

File tree

4 files changed

+60
-1
lines changed

4 files changed

+60
-1
lines changed

src/stresty/core.clj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@
3232

3333
(def marata-test
3434
(do
35-
(prn "---------------------------------------------")
35+
;;(prn "---------------------------------------------")
3636
;;(-main "--path=/Users/aitem/Work/HS/ssty/t" "--ns=rmis" "tests")
3737
(prn "---------------------------------------------")
3838
(-main "--path=/Users/aitem/Work/HS/ssty/t" "--format=stdout" "--ns=rmis" "tests")
39+
(prn "---------------------------------------------")
40+
(def p (-main "--path=/Users/aitem/Work/HS/ssty/t" "--format=report" "--ns=rmis" "tests"))
3941
))
4042

4143
(def ctx (-main "server" "--port=8888"))

src/stresty/format/report.clj

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
(ns stresty.format.report
2+
(:require [stresty.format.core :as fmt]
3+
[clojure.string :as str]))
4+
5+
(defmethod fmt/do-format
6+
'sty/report-fmt
7+
[ztx _ state {tp :type ts :ts :as event}]
8+
(cond
9+
(= tp 'sty/on-tests-start)
10+
(swap! state assoc :start ts)
11+
12+
(= tp 'sty/on-zen-errors)
13+
(do
14+
(println "Syntax errors:")
15+
(println (str/join "\n"
16+
(->>
17+
(:errors event)
18+
(mapv (fn [{msg :message res :resource pth :path}]
19+
(str ">> " msg " in " res " at " pth)))))))
20+
21+
(= tp 'sty/on-env-start)
22+
(print (get-in event [:env :zen/name]) "{")
23+
24+
(= tp 'sty/on-case-start)
25+
(print "(")
26+
27+
(= tp 'sty/on-step-start)
28+
:nop
29+
30+
(tp (set ['sty/on-step-success 'sty/on-match-ok]))
31+
(print ".")
32+
33+
(tp (set ['sty/on-step-fail 'sty/on-match-fail]))
34+
(print "x")
35+
36+
;;(= tp 'sty/tests-summary)
37+
;;(summary ztx)
38+
39+
(= tp 'sty/on-step-exception)
40+
(print "!")
41+
42+
(= tp 'sty/on-case-end)
43+
(print ")")
44+
45+
(= tp 'sty/on-env-end)
46+
(print "}\n")
47+
48+
49+
(= tp 'sty/tests-done)
50+
(print "done \n")
51+
52+
)
53+
54+
)

src/stresty/operations/core.clj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
(let [env (zen/get-symbol ztx env-ref)]
108108
(run-env ztx env)))
109109
(fmt/emit ztx {:type 'sty/tests-summary})
110+
(fmt/emit ztx {:type 'sty/tests-done})
110111
{:result params})
111112

112113
(defmethod call-op 'sty/gen

src/stresty/server/core.clj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
[stresty.server.cli]
88
[stresty.operations.core]
99
[stresty.format.core :as fmt]
10+
[stresty.format.report]
1011
[stresty.sci]
1112
[clojure.string :as str]))
1213

@@ -64,6 +65,7 @@ sty => help
6465
(swap! ztx assoc :opts opts :formatters
6566
(let [fmt (get {"ndjson" 'sty/ndjson-fmt
6667
"stdout" 'sty/stdout-fmt
68+
"report" 'sty/report-fmt ;; html report
6769
"debug" 'sty/debug-fmt}
6870
(:format opts)
6971
'sty/debug-fmt)]

0 commit comments

Comments
 (0)