diff --git a/src/path/filepath/path_test.go b/src/path/filepath/path_test.go index ed3990859bf..c96a758c695 100644 --- a/src/path/filepath/path_test.go +++ b/src/path/filepath/path_test.go @@ -1403,6 +1403,9 @@ func TestAbs(t *testing.T) { } } + // Make sure the global absTests slice is not + // modified by multiple invocations of TestAbs. + tests := absTests if runtime.GOOS == "windows" { vol := filepath.VolumeName(root) var extra []string @@ -1413,7 +1416,7 @@ func TestAbs(t *testing.T) { path = vol + path extra = append(extra, path) } - absTests = append(absTests, extra...) + tests = append(slices.Clip(tests), extra...) } err = os.Chdir(absTestDirs[0]) @@ -1421,7 +1424,7 @@ func TestAbs(t *testing.T) { t.Fatal("chdir failed: ", err) } - for _, path := range absTests { + for _, path := range tests { path = strings.ReplaceAll(path, "$", root) info, err := os.Stat(path) if err != nil {