e2e framework: adapt unit test to Go 1.22

Go 1.22 changed the name of init functions from "glob..func" to
"init.func". That difference is acceptable and has to be ignored when comparing
output.
This commit is contained in:
Patrick Ohly 2023-09-19 12:18:34 +02:00
parent f7dacb63cc
commit 83c37acb21

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
}