@@ -19,6 +19,7 @@ import (
1919 "path/filepath"
2020 "reflect"
2121 "runtime"
22+ "slices"
2223 "sort"
2324 "strings"
2425 "sync"
@@ -63,14 +64,7 @@ func TestMain(m *testing.M) {
6364
6465func matchSkipConditions (conditions ... string ) bool {
6566 for _ , cond := range conditions {
66- condfound := false
67- for _ , s := range []string {runtime .GOOS , runtime .GOARCH , testBackend , buildMode } {
68- if s == cond {
69- condfound = true
70- break
71- }
72- }
73- if ! condfound {
67+ if ! slices .Contains ([]string {runtime .GOOS , runtime .GOARCH , testBackend , buildMode }, cond ) {
7468 return false
7569 }
7670 }
@@ -183,14 +177,7 @@ func assertLineNumber(p *proc.Target, t *testing.T, lineno int, descr string) (s
183177
184178func assertLineNumberIn (p * proc.Target , t * testing.T , linenos []int , descr string ) (string , int ) {
185179 f , l := currentLineNumber (p , t )
186- found := false
187- for _ , lineno := range linenos {
188- if l == lineno {
189- found = true
190- break
191- }
192- }
193- if ! found {
180+ if ! slices .Contains (linenos , l ) {
194181 _ , callerFile , callerLine , _ := runtime .Caller (1 )
195182 t .Fatalf ("%s expected lines :%#v got %s:%d\n \t at %s:%d" , descr , linenos , f , l , callerFile , callerLine )
196183 }
@@ -4012,21 +3999,12 @@ func TestDeadlockBreakpoint(t *testing.T) {
40123999 })
40134000}
40144001
4015- func findSource (source string , sources []string ) bool {
4016- for _ , s := range sources {
4017- if s == source {
4018- return true
4019- }
4020- }
4021- return false
4022- }
4023-
40244002func TestListImages (t * testing.T ) {
40254003 protest .MustHaveCgo (t )
40264004 pluginFixtures := protest .WithPlugins (t , protest .AllNonOptimized , "plugin1/" , "plugin2/" )
40274005
40284006 withTestProcessArgs ("plugintest" , t , "." , []string {pluginFixtures [0 ].Path , pluginFixtures [1 ].Path }, protest .AllNonOptimized , func (p * proc.Target , grp * proc.TargetGroup , fixture protest.Fixture ) {
4029- if ! findSource ( fixture . Source , p .BinInfo ().Sources ) {
4007+ if ! slices . Contains ( p .BinInfo ().Sources , fixture . Source ) {
40304008 t .Fatalf ("could not find %s in sources: %q\n " , fixture .Source , p .BinInfo ().Sources )
40314009 }
40324010
@@ -4043,7 +4021,7 @@ func TestListImages(t *testing.T) {
40434021 if ! plugin1Found {
40444022 t .Fatalf ("Could not find plugin1" )
40454023 }
4046- if ! findSource ( fixture . Source , p .BinInfo ().Sources ) {
4024+ if ! slices . Contains ( p .BinInfo ().Sources , fixture . Source ) {
40474025 // Source files for the base program must be available even after a plugin is loaded. Issue #2074.
40484026 t .Fatalf ("could not find %s in sources (after loading plugin): %q\n " , fixture .Source , p .BinInfo ().Sources )
40494027 }
0 commit comments