From: Than McIntosh Date: Wed, 3 May 2023 17:40:02 +0000 (-0400) Subject: runtime/coverage: fix problematic test from issue 59563 X-Git-Tag: go1.21rc1~702 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=91a716a043f01334e7e6d28af4863d2188ffb336;p=gostls13.git runtime/coverage: fix problematic test from issue 59563 Fix up the coverage testpoint TestIssue59563TruncatedCoverPkgAll to avoid spurious failures due to racy behavior. Specifically, we are only interested in verifying coverage for the larger function of the two in the test package (the smaller one is only there to trigger additional function registrations while the test is finalizing the cov data). Updates #59867. Updates #59563. Change-Id: Ibfbbcbf68e0ad7a4d9606cbcfc69d140375c7b87 Reviewed-on: https://go-review.googlesource.com/c/go/+/492175 Run-TryBot: Than McIntosh Auto-Submit: Than McIntosh TryBot-Result: Gopher Robot Reviewed-by: David Chase Reviewed-by: Cherry Mui --- diff --git a/src/runtime/coverage/emitdata_test.go b/src/runtime/coverage/emitdata_test.go index b0bd0e5c21..3558dd2d88 100644 --- a/src/runtime/coverage/emitdata_test.go +++ b/src/runtime/coverage/emitdata_test.go @@ -527,7 +527,10 @@ func TestIssue59563TruncatedCoverPkgAll(t *testing.T) { if len(f) == 0 { continue } - if !strings.HasPrefix(f[0], "runtime/coverage/testdata/issue59563/repro.go") { + // We're only interested in the specific function "large" for + // the testcase being built. See the #59563 for details on why + // size matters. + if !(strings.HasPrefix(f[0], "runtime/coverage/testdata/issue59563/repro.go") && strings.Contains(line, "large")) { continue } nfound++ @@ -537,8 +540,8 @@ func TestIssue59563TruncatedCoverPkgAll(t *testing.T) { bad = true } } - if nfound != 2 { - t.Errorf("wanted 2 found, got %d\n", nfound) + if nfound != 1 { + t.Errorf("wanted 1 found, got %d\n", nfound) bad = true } if bad {