Skip to content

Commit

Permalink
go/analysis/passes/copylock: enable unfortunate tests
Browse files Browse the repository at this point in the history
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 <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
  • Loading branch information
mknyszek committed Nov 18, 2024
1 parent 39cb6f0 commit acc2a74
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
6 changes: 1 addition & 5 deletions go/analysis/passes/copylock/copylock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit acc2a74

Please sign in to comment.