diff --git a/go.mod b/go.mod index 12e0b28e5ebd..ae26c3f16982 100644 --- a/go.mod +++ b/go.mod @@ -78,7 +78,6 @@ require ( github.com/mattn/go-colorable v0.1.13 github.com/mgechev/revive v1.5.1 github.com/mitchellh/go-homedir v1.1.0 - github.com/mitchellh/go-ps v1.0.0 github.com/moricho/tparallel v0.3.2 github.com/nakabonne/nestif v0.3.1 github.com/nishanths/exhaustive v0.12.0 diff --git a/go.sum b/go.sum index bddf925521b0..1ba2ced4ed35 100644 --- a/go.sum +++ b/go.sum @@ -389,8 +389,6 @@ github.com/mgechev/revive v1.5.1 h1:hE+QPeq0/wIzJwOphdVyUJ82njdd8Khp4fUIHGZHW3M= github.com/mgechev/revive v1.5.1/go.mod h1:lC9AhkJIBs5zwx8wkudyHrU+IJkrEKmpCmGMnIJPk4o= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc= -github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= diff --git a/test/bench/bench_test.go b/test/bench/bench_test.go index 4c885f46c8c8..c54fcde870ca 100644 --- a/test/bench/bench_test.go +++ b/test/bench/bench_test.go @@ -15,7 +15,6 @@ import ( "testing" "time" - gops "github.com/mitchellh/go-ps" "github.com/shirou/gopsutil/v4/process" "github.com/stretchr/testify/require" @@ -251,16 +250,20 @@ func countGoLines(tb testing.TB) int { func getLinterMemoryMB(tb testing.TB) (int, error) { tb.Helper() - processes, err := gops.Processes() + processes, err := process.Processes() if err != nil { tb.Fatalf("can't get processes: %s", err) } - var progPID int + var progPID int32 for _, p := range processes { + exe, err := p.Exe() + if err != nil { + continue + } // The executable name can be shorter than the binary name. - if strings.HasPrefix(binName, p.Executable()) { - progPID = p.Pid() + if strings.HasPrefix(binName, filepath.Base(exe)) { + progPID = p.Pid break } } @@ -268,16 +271,20 @@ func getLinterMemoryMB(tb testing.TB) (int, error) { return 0, errors.New("no process") } - allProgPIDs := []int{progPID} + allProgPIDs := []int32{progPID} for _, p := range processes { - if p.PPid() == progPID { - allProgPIDs = append(allProgPIDs, p.Pid()) + ppid, err := p.Ppid() + if err != nil { + continue + } + if ppid == progPID { + allProgPIDs = append(allProgPIDs, p.Pid) } } var totalProgMemBytes uint64 for _, pid := range allProgPIDs { - p, err := process.NewProcess(int32(pid)) + p, err := process.NewProcess(pid) if err != nil { continue // subprocess could die }