File tree Expand file tree Collapse file tree 2 files changed +40
-5
lines changed
Expand file tree Collapse file tree 2 files changed +40
-5
lines changed Original file line number Diff line number Diff line change @@ -255,22 +255,22 @@ const (
255255 desc = `
256256{{- if .Message }}
257257{code:title=Message|borderStyle=solid}
258- {{ .Message }}
258+ {{ .Message | truncate }}
259259{code}
260260{{- end }}
261261{{- if .Stderr }}
262262{code:title=STDERR|borderStyle=solid}
263- {{ .Stderr }}
263+ {{ .Stderr | truncate }}
264264{code}
265265{{- end }}
266266{{- if .Stdout }}
267267{code:title=STDOUT|borderStyle=solid}
268- {{ .Stdout }}
268+ {{ .Stdout | truncate }}
269269{code}
270270{{- end }}
271271{{- if .Error }}
272272{code:title=ERROR|borderStyle=solid}
273- {{ .Error }}
273+ {{ .Error | truncate }}
274274{code}
275275{{- end }}
276276
@@ -352,7 +352,7 @@ func (tc *testCase) addSubTest(subTest junit.Test) {
352352}
353353
354354func render (tc testCase , text string ) (string , error ) {
355- tmpl , err := template .New ("test" ).Parse (text )
355+ tmpl , err := template .New ("test" ).Funcs ( map [ string ] any { "truncate" : truncate }). Parse (text )
356356 if err != nil {
357357 return "" , err
358358 }
@@ -372,3 +372,13 @@ func clearString(str string) string {
372372 return ' '
373373 }, str )
374374}
375+
376+ var maxTextBlockLength = 10000
377+
378+ func truncate (s string ) string {
379+ runes := []rune (s )
380+ if len (runes ) > maxTextBlockLength {
381+ return string (runes [:maxTextBlockLength ]) + "\n … too long, truncated."
382+ }
383+ return s
384+ }
Original file line number Diff line number Diff line change @@ -230,4 +230,29 @@ org.spockframework.runtime.ConditionNotSatisfiedError: Condition not satisfied:
230230 s , err := tc .summary ()
231231 assert .NoError (t , err )
232232 assert .Equal (t , `DefaultPoliciesTest / Verify policy Apache Struts CVE-2017-5638 is triggered FAILED` , s )
233+
234+ maxTextBlockLength = 100
235+ actual , err = tc .description ()
236+ assert .NoError (t , err )
237+ assert .Equal (t , `
238+ {code:title=Message|borderStyle=solid}
239+ Condition not satisfied:
240+
241+ waitForViolation(deploymentName, policyName, 60)
242+ | |
243+ … too long, truncated.
244+ {code}
245+ {code:title=STDOUT|borderStyle=solid}
246+ ?[1;30m21:35:15?[0;39m | ?[34mINFO ?[0;39m | DefaultPoliciesTest | Starting testcase
247+ ?[1;30m21
248+ … too long, truncated.
249+ {code}
250+
251+ || ENV || Value ||
252+ | BUILD ID | [1|https://prow.ci.openshift.org/view/gs/origin-ci-test/logs//1]|
253+ | BUILD TAG | [|]|
254+ | JOB NAME ||
255+ | CLUSTER ||
256+ | ORCHESTRATOR ||
257+ ` , actual )
233258}
You can’t perform that action at this time.
0 commit comments