Merge pull request #120750 from pohly/test-output-init-fix

e2e framework: adapt unit test to Go 1.22
This commit is contained in:
Kubernetes Prow Robot 2023-09-27 06:26:10 -07:00 committed by GitHub
commit d924775d78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -110,6 +110,7 @@ func simplify(in string, expected TestResult) string {
out := normalizeLocation(in)
out = stripTimes(out)
out = stripAddresses(out)
out = normalizeInitFunctions(out)
if expected.NormalizeOutput != nil {
out = expected.NormalizeOutput(out)
}
@ -178,3 +179,12 @@ func normalizeLocation(in string) string {
out = klogPrefix.ReplaceAllString(out, "<klog> ")
return out
}
var initFunc = regexp.MustCompile(`(init\.+func|glob\.+func)`)
// normalizeInitFunctions maps both init.func (used by Go >= 1.22) and
// glob..func (used by Go < 1.22) to <init.func>.
func normalizeInitFunctions(in string) string {
out := initFunc.ReplaceAllString(in, "<init.func>")
return out
}