mk: remove json-to-junit program
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
Jakub Sztandera committed
Mar 5, 2019 at 18:38 UTC
c21b7f91bc3c3dc4229b9a85d2d2333a0e122a72
1 file changed
-135
test/dependencies/json-to-junit/main.go
deleted
-135
@@ -1,135 +0,0 @@
1
-package main
2
-
3
-import (
4
- "bufio"
5
- "encoding/json"
6
- "encoding/xml"
7
- "log"
8
- "os"
9
-)
10
-
11
-type testMsg struct {
12
- Time string
13
- Action string
14
- Package string
15
- Test string
16
- Output string
17
- Elapsed float64
18
-}
19
-
20
-type testsuites struct {
21
- XMLName xml.Name `xml:"testsuites"`
22
- Name string `xml:"name,attr"`
23
- Testsuites []testsuite
24
-}
25
-
26
-type testsuite struct {
27
- XMLName xml.Name `xml:"testsuite"`
28
- Package string `xml:"package,attr"`
29
- Errors int `xml:"errors,attr"`
30
- Failures int `xml:"failures,attr"`
31
- Tests int `xml:"tests,attr"`
32
- Time float64 `xml:"time,attr"`
33
- Testcases []testcase
34
-}
35
-
36
-type testcase struct {
37
- XMLName xml.Name `xml:"testcase"`
38
- Name string `xml:"name,attr"`
39
- Classname string `xml:"classname,attr"`
40
- Time float64 `xml:"time,attr"`
41
- Sout string `xml:"system-out"`
42
- Serr string `xml:"system-err"`
43
- Skipped string `xml:"skipped,omitempty"`
44
- Failure string `xml:"failure,omitempty"`
45
-}
46
-
47
-func main() {
48
- scanner := bufio.NewScanner(os.Stdin)
49
- tests := make(map[string]map[string]testcase)
50
- var fails int
51
- var packages []testsuite
52
- for scanner.Scan() {
53
- msg := testMsg{}
54
- if err := json.Unmarshal(scanner.Bytes(), &msg); err != nil {
55
- log.Fatal(err)
56
- }
57
-
58
- switch {
59
- case msg.Action == "run":
60
- if tests[msg.Package] == nil {
61
- tests[msg.Package] = make(map[string]testcase)
62
- }
63
-
64
- tests[msg.Package][msg.Test] = testcase{
65
- Name: msg.Test,
66
- Classname: msg.Package,
67
- }
68
- case msg.Action == "output":
69
- if msg.Test == "" {
70
- continue
71
- }
72
-
73
- test := tests[msg.Package][msg.Test]
74
- test.Sout = test.Sout + msg.Output + "\n"
75
- tests[msg.Package][msg.Test] = test
76
- case msg.Action == "skip":
77
- fallthrough
78
- case msg.Action == "fail":
79
- fallthrough
80
- case msg.Action == "pass":
81
- if msg.Test != "" {
82
- test := tests[msg.Package][msg.Test]
83
- test.Time = msg.Elapsed
84
-
85
- if msg.Action == "skip" {
86
- test.Skipped = "skipped"
87
- }
88
-
89
- if msg.Action == "fail" {
90
- fails++
91
- test.Failure = "failed"
92
- }
93
-
94
- tests[msg.Package][msg.Test] = test
95
- continue
96
- }
97
-
98
- ts := testsuite{
99
- Package: msg.Package,
100
- Time: msg.Elapsed,
101
- }
102
-
103
- for _, test := range tests[msg.Package] {
104
- ts.Testcases = append(ts.Testcases, test)
105
- ts.Tests++
106
- if test.Failure != "" {
107
- ts.Failures++
108
- }
109
- }
110
- packages = append(packages, ts)
111
- case msg.Action == "cont":
112
- case msg.Action == "pause":
113
- // ??
114
- default:
115
- log.Fatalf("unknown action %s", msg.Action)
116
- }
117
- }
118
-
119
- if err := scanner.Err(); err != nil {
120
- log.Fatal(err)
121
- }
122
-
123
- out := testsuites{
124
- Name: "go test",
125
- Testsuites: packages,
126
- }
127
-
128
- output, err := xml.MarshalIndent(&out, " ", " ")
129
- if err != nil {
130
- log.Fatalf("error: %v\n", err)
131
- }
132
-
133
- os.Stdout.Write(output)
134
- os.Exit(fails)
135
-}