From acc2a7418d6022b9b7ffb6a9519d0a143c1d2080 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Mon, 18 Nov 2024 17:35:34 +0000 Subject: [PATCH] go/analysis/passes/copylock: enable unfortunate tests CL 628435 moved and disabled these tests. This CL re-enables them for the time when CL 627777 lands. Change-Id: I16cb8d4c23db35fadaac94054183f26bba2449e2 Reviewed-on: https://go-review.googlesource.com/c/tools/+/629235 LUCI-TryBot-Result: Go LUCI Reviewed-by: Tim King Reviewed-by: Alan Donovan --- go/analysis/passes/copylock/copylock_test.go | 6 +----- .../passes/copylock/testdata/src/unfortunate/local_go123.go | 2 +- .../passes/copylock/testdata/src/unfortunate/local_go124.go | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/go/analysis/passes/copylock/copylock_test.go b/go/analysis/passes/copylock/copylock_test.go index 7667f35b4..ae249b1ac 100644 --- a/go/analysis/passes/copylock/copylock_test.go +++ b/go/analysis/passes/copylock/copylock_test.go @@ -16,11 +16,7 @@ import ( func Test(t *testing.T) { testdata := analysistest.TestData() - // TODO(mknyszek): Add "unfortunate" package once CL 627777 lands. That CL changes - // the internals of the sync package structures to carry an explicit noCopy to prevent - // problems from changes to the implementations of those structures, such as these - // tests failing, or a bad user experience. - analysistest.Run(t, testdata, copylock.Analyzer, "a", "typeparams", "issue67787") + analysistest.Run(t, testdata, copylock.Analyzer, "a", "typeparams", "issue67787", "unfortunate") } func TestVersions22(t *testing.T) { diff --git a/go/analysis/passes/copylock/testdata/src/unfortunate/local_go123.go b/go/analysis/passes/copylock/testdata/src/unfortunate/local_go123.go index 1aa3abc78..c6bc0256b 100644 --- a/go/analysis/passes/copylock/testdata/src/unfortunate/local_go123.go +++ b/go/analysis/passes/copylock/testdata/src/unfortunate/local_go123.go @@ -15,7 +15,7 @@ import "sync" // sync.Mutex gets called out, but without any reference to the sync.Once. type LocalOnce sync.Once -func (LocalOnce) Bad() {} // want `Bad passes lock by value: a.LocalOnce contains sync.\b.*` +func (LocalOnce) Bad() {} // want `Bad passes lock by value: unfortunate.LocalOnce contains sync.\b.*` // False negative: // LocalMutex doesn't have a Lock method. diff --git a/go/analysis/passes/copylock/testdata/src/unfortunate/local_go124.go b/go/analysis/passes/copylock/testdata/src/unfortunate/local_go124.go index 505b105a9..5f45402f7 100644 --- a/go/analysis/passes/copylock/testdata/src/unfortunate/local_go124.go +++ b/go/analysis/passes/copylock/testdata/src/unfortunate/local_go124.go @@ -12,8 +12,8 @@ import "sync" type LocalOnce sync.Once -func (LocalOnce) Bad() {} // want "Bad passes lock by value: a.LocalOnce contains sync.noCopy" +func (LocalOnce) Bad() {} // want "Bad passes lock by value: unfortunate.LocalOnce contains sync.noCopy" type LocalMutex sync.Mutex -func (LocalMutex) Bad() {} // want "Bad passes lock by value: a.LocalMutex contains sync.noCopy" +func (LocalMutex) Bad() {} // want "Bad passes lock by value: unfortunate.LocalMutex contains sync.noCopy"