@@ -23,6 +23,8 @@ type TestEvent struct {
23
23
Output string
24
24
}
25
25
26
+ var buildOutput []string
27
+
26
28
func ParseTestResults (r io.Reader , verbose bool , env * ctrf.Environment ) (* ctrf.Report , error ) {
27
29
var testEvents []TestEvent
28
30
decoder := json .NewDecoder (r )
@@ -47,6 +49,43 @@ func ParseTestResults(r io.Reader, verbose bool, env *ctrf.Environment) (*ctrf.R
47
49
}
48
50
fmt .Println (string (jsonEvent ))
49
51
}
52
+
53
+ if event .Action == "build-output" || event .Action == "build-fail" || event .Action == "fail" {
54
+ if report .Results .Extra == nil {
55
+ report .Results .Extra = make (map [string ]interface {})
56
+ }
57
+ extraMap := report .Results .Extra .(map [string ]interface {})
58
+
59
+ if event .Action == "fail" {
60
+ if _ , ok := extraMap ["FailedBuild" ]; ! ok {
61
+ extraMap ["FailedBuild" ] = true
62
+ }
63
+ }
64
+
65
+ if event .Action == "build-output" {
66
+ if _ , ok := extraMap ["buildOutput" ]; ! ok {
67
+ extraMap ["buildOutput" ] = []TestEvent {}
68
+ }
69
+ buildOutputEvents := extraMap ["buildOutput" ].([]TestEvent )
70
+ extraMap ["buildOutput" ] = append (buildOutputEvents , event )
71
+ buildOutput = append (buildOutput , event .Output )
72
+ continue
73
+ }
74
+
75
+ if event .Action == "build-fail" {
76
+ if _ , ok := extraMap ["buildFail" ]; ! ok {
77
+ extraMap ["buildFail" ] = []TestEvent {}
78
+ }
79
+ buildFailEvents := extraMap ["buildFail" ].([]TestEvent )
80
+ extraMap ["buildFail" ] = append (buildFailEvents , event )
81
+ break
82
+ }
83
+ }
84
+
85
+ if event .Action == "output" {
86
+ buildOutput = append (buildOutput , event .Output )
87
+ }
88
+
50
89
if event .Test == "" {
51
90
continue
52
91
}
@@ -162,6 +201,10 @@ func WriteReportToFile(filename string, report *ctrf.Report) error {
162
201
return nil
163
202
}
164
203
204
+ func GetBuildOutput () string {
205
+ return strings .Join (buildOutput , "" )
206
+ }
207
+
165
208
func secondsToMillis (seconds float64 ) int64 {
166
209
return int64 (seconds * 1000 )
167
210
}
0 commit comments