From 99d63007a00c07bdb9571d2a206c55b72fe1295e Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Mon, 16 May 2022 12:14:14 -0700 Subject: [PATCH] test: fix issue20014 for noopt builder This test is currently overly sensitive to compiler optimizations, because inlining can affect the order in which cmd/link emits field references. The order doesn't actually matter though, so this CL just tweaks the test to sort the tracked fields before printing them. Updates #51734. Change-Id: I3b65ca265856b2e1102f40406d5ce34610c70d40 Reviewed-on: https://go-review.googlesource.com/c/go/+/406674 Run-TryBot: Matthew Dempsky Reviewed-by: David Chase TryBot-Result: Gopher Robot --- test/fixedbugs/issue20014.dir/main.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/fixedbugs/issue20014.dir/main.go b/test/fixedbugs/issue20014.dir/main.go index ac9957de40..098ac6b99a 100644 --- a/test/fixedbugs/issue20014.dir/main.go +++ b/test/fixedbugs/issue20014.dir/main.go @@ -5,6 +5,7 @@ package main import ( + "sort" "strings" "issue20014.dir/a" @@ -13,12 +14,17 @@ import ( func main() { samePackage() crossPackage() + // Print fields registered with field tracking. + var fields []string for _, line := range strings.Split(fieldTrackInfo, "\n") { - if line == "" { - continue + if line != "" { + fields = append(fields, strings.Split(line, "\t")[0]) } - println(strings.Split(line, "\t")[0]) + } + sort.Strings(fields) // for stable output, regardless of optimizations + for _, field := range fields { + println(field) } } -- 2.48.1