mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-02 19:28:16 +00:00
prune-junit-xml: smarter concatenation when pruning tests
Repeating the same "Failed" message text doesn't add any
information. Separating with a blank line is more readable.
Before:
<failure message="Failed; Failed; Failed" type="">
...
--- FAIL: TestFrontProxyConfig/WithoutUID (64.89s) ; === RUN TestFrontProxyConfig/WithUID
After:
<failure message="Failed" type="">
...
--- FAIL: TestFrontProxyConfig/WithoutUID (64.89s)
=== RUN TestFrontProxyConfig/WithUID
This commit is contained in:
@@ -153,8 +153,15 @@ func pruneTESTS(suites *junitxml.JUnitTestSuites) {
|
||||
suites.Suites = updatedTestsuites
|
||||
}
|
||||
|
||||
// joinTexts returns "<a>; <b>" if both are non-empty,
|
||||
// joinTexts returns "<a><empty line><b>" if both are non-empty,
|
||||
// otherwise just the non-empty string, if there is one.
|
||||
//
|
||||
// If <b> is contained completely in <a>, <a> gets returned because repeating
|
||||
// exactly the same string again doesn't add any information. Typically
|
||||
// this occurs when joining the failure message because that is the fixed
|
||||
// string "Failed" for all tests, regardless of what the test logged.
|
||||
// The test log output is typically different because it cointains "=== RUN
|
||||
// <test name>" and thus doesn't get dropped.
|
||||
func joinTexts(a, b string) string {
|
||||
if a == "" {
|
||||
return b
|
||||
@@ -162,7 +169,14 @@ func joinTexts(a, b string) string {
|
||||
if b == "" {
|
||||
return a
|
||||
}
|
||||
return a + "; " + b
|
||||
if strings.Contains(a, b) {
|
||||
return a
|
||||
}
|
||||
sep := "\n"
|
||||
if !strings.HasSuffix(a, "\n") {
|
||||
sep = "\n\n"
|
||||
}
|
||||
return a + sep + b
|
||||
}
|
||||
|
||||
func fetchXML(xmlReader io.Reader) (*junitxml.JUnitTestSuites, error) {
|
||||
|
||||
Reference in New Issue
Block a user