1
0
mirror of https://github.com/golang/go synced 2024-09-30 07:18:34 -06:00

os: simplify check whether to run subtest of TestRemoveAll

Change-Id: Ic5b46cfb393f5ba7b91b3fb73b158b0bc238a532
GitHub-Last-Rev: e5c5db51bc
GitHub-Pull-Request: golang/go#30019
Reviewed-on: https://go-review.googlesource.com/c/go/+/160443
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Leon Klingele 2019-03-03 13:10:59 +00:00 committed by Ian Lance Taylor
parent b6625758e4
commit 4e20d999ec

View File

@ -80,16 +80,8 @@ func TestRemoveAll(t *testing.T) {
t.Fatalf("Lstat %q succeeded after RemoveAll (third)", path) t.Fatalf("Lstat %q succeeded after RemoveAll (third)", path)
} }
// Determine if we should run the following test. // Chmod is not supported under Windows and test fails as root.
testit := true if runtime.GOOS != "windows" && Getuid() != 0 {
if runtime.GOOS == "windows" {
// Chmod is not supported under windows.
testit = false
} else {
// Test fails as root.
testit = Getuid() != 0
}
if testit {
// Make directory with file and subdirectory and trigger error. // Make directory with file and subdirectory and trigger error.
if err = MkdirAll(dpath, 0777); err != nil { if err = MkdirAll(dpath, 0777); err != nil {
t.Fatalf("MkdirAll %q: %s", dpath, err) t.Fatalf("MkdirAll %q: %s", dpath, err)