try deleting a directory before resetting the readonly status in tests

This commit is contained in:
Michael Eischer
2026-06-16 19:38:00 +02:00
parent f394723aa2
commit 52cde35aea
+6 -2
View File
@@ -195,8 +195,12 @@ func resetReadOnly(t testing.TB, dir string) {
// afterwards uses os.RemoveAll() to remove the path.
func RemoveAll(t testing.TB, path string) {
t.Helper()
resetReadOnly(t, path)
err := os.RemoveAll(path)
var err error
err = os.RemoveAll(path)
if err != nil {
resetReadOnly(t, path)
err = os.RemoveAll(path)
}
if errors.Is(err, os.ErrNotExist) {
err = nil
}