aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2022-03-02 16:36:27 -0500
committerCherry Mui <cherryyz@google.com>2022-07-25 23:29:29 +0000
commitd06c911fe110c5ddfc47d5f6467b8bc88a573b52 (patch)
tree05f16a3e8658ff0e5c808c1baf2ec94310384178
parentd252fdd630a51db206194b3c41c3d036fdd6f48a (diff)
downloadgo-d06c911fe110c5ddfc47d5f6467b8bc88a573b52.tar.gz
go-d06c911fe110c5ddfc47d5f6467b8bc88a573b52.zip
[release-branch.go1.18] testing: include ERROR_SHARING_VIOLATION in Windows cleanup retries
Fixes #52986 Updates #51442 Updates #50051 Change-Id: I1bfbc08c907077467fd50febbec6299a9b73af41 Reviewed-on: https://go-review.googlesource.com/c/go/+/388916 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> (cherry picked from commit eeb9f095dc13a6beed41db0e734b6ae1e97f15d1) Reviewed-on: https://go-review.googlesource.com/c/go/+/407877 Reviewed-by: Nooras Saba‎ <saba@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com>
-rw-r--r--src/testing/testing.go2
-rw-r--r--src/testing/testing_other.go6
-rw-r--r--src/testing/testing_windows.go22
3 files changed, 22 insertions, 8 deletions
diff --git a/src/testing/testing.go b/src/testing/testing.go
index df4dfe4490..05d8f22aff 100644
--- a/src/testing/testing.go
+++ b/src/testing/testing.go
@@ -1122,7 +1122,7 @@ func removeAll(path string) error {
)
for {
err := os.RemoveAll(path)
- if !isWindowsAccessDenied(err) {
+ if !isWindowsRetryable(err) {
return err
}
if start.IsZero() {
diff --git a/src/testing/testing_other.go b/src/testing/testing_other.go
index 29496d81bc..99a6276a4a 100644
--- a/src/testing/testing_other.go
+++ b/src/testing/testing_other.go
@@ -6,8 +6,8 @@
package testing
-// isWindowsAccessDenied reports whether err is ERROR_ACCESS_DENIED,
-// which is defined only on Windows.
-func isWindowsAccessDenied(err error) bool {
+// isWindowsRetryable reports whether err is a Windows error code
+// that may be fixed by retrying a failed filesystem operation.
+func isWindowsRetryable(err error) bool {
return false
}
diff --git a/src/testing/testing_windows.go b/src/testing/testing_windows.go
index bc76cb80cc..fd48ae9579 100644
--- a/src/testing/testing_windows.go
+++ b/src/testing/testing_windows.go
@@ -8,11 +8,25 @@ package testing
import (
"errors"
+ "internal/syscall/windows"
"syscall"
)
-// isWindowsAccessDenied reports whether err is ERROR_ACCESS_DENIED,
-// which is defined only on Windows.
-func isWindowsAccessDenied(err error) bool {
- return errors.Is(err, syscall.ERROR_ACCESS_DENIED)
+// isWindowsRetryable reports whether err is a Windows error code
+// that may be fixed by retrying a failed filesystem operation.
+func isWindowsRetryable(err error) bool {
+ for {
+ unwrapped := errors.Unwrap(err)
+ if unwrapped == nil {
+ break
+ }
+ err = unwrapped
+ }
+ if err == syscall.ERROR_ACCESS_DENIED {
+ return true // Observed in https://go.dev/issue/50051.
+ }
+ if err == windows.ERROR_SHARING_VIOLATION {
+ return true // Observed in https://go.dev/issue/51442.
+ }
+ return false
}