From 187cccbde167f6979fb026524eea1004ec1d625a Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Mon, 2 Feb 2015 17:40:47 +0100 Subject: [PATCH] os: fix TestMkdirAllAtSlash on Plan 9 Since CL 3676, the TestMkdirAllAtSlash test depends on syscall.EROFS, which isn't defined on Plan 9. This change works around this issue by defining a system dependent isReadonlyError function. Change-Id: If972fd2fe4828ee3bcb8537ea7f4ba29f7a87619 Reviewed-on: https://go-review.googlesource.com/3696 Reviewed-by: Brad Fitzpatrick --- src/os/os_unix_test.go | 4 ++++ src/os/path_test.go | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/os/os_unix_test.go b/src/os/os_unix_test.go index 21d40ccaf8..afee189650 100644 --- a/src/os/os_unix_test.go +++ b/src/os/os_unix_test.go @@ -13,6 +13,10 @@ import ( "testing" ) +func init() { + isReadonlyError = func(err error) bool { return err == syscall.EROFS } +} + func checkUidGid(t *testing.T, path string, uid, gid int) { dir, err := Stat(path) if err != nil { diff --git a/src/os/path_test.go b/src/os/path_test.go index 7252e870ce..66ed49b6fd 100644 --- a/src/os/path_test.go +++ b/src/os/path_test.go @@ -13,6 +13,8 @@ import ( "testing" ) +var isReadonlyError = func(error) bool { return false } + func TestMkdirAll(t *testing.T) { tmpDir := TempDir() path := tmpDir + "/_TestMkdirAll_/dir/./dir2" @@ -212,7 +214,7 @@ func TestMkdirAllAtSlash(t *testing.T) { if err != nil { pathErr, ok := err.(*PathError) // common for users not to be able to write to / - if ok && (pathErr.Err == syscall.EACCES || pathErr.Err == syscall.EROFS) { + if ok && (pathErr.Err == syscall.EACCES || isReadonlyError(pathErr.Err)) { t.Skipf("could not create %v: %v", dir, err) } t.Fatalf(`MkdirAll "/_go_os_test/dir": %v`, err) -- 2.48.1