t.Skip("skipping for not implemented platforms")
}
- prevDir, err := Getwd()
- if err != nil {
- t.Fatalf("Could not get wd: %s", err)
- }
+ startPath := t.TempDir()
+ t.Chdir(startPath)
- startPath, err := MkdirTemp("", "TestRemoveAllLongPath-")
- if err != nil {
- t.Fatalf("Could not create TempDir: %s", err)
- }
- defer RemoveAll(startPath)
-
- err = Chdir(startPath)
- if err != nil {
- t.Fatalf("Could not chdir %s: %s", startPath, err)
- }
-
- // Removing paths with over 4096 chars commonly fails
+ // Removing paths with over 4096 chars commonly fails.
+ name := strings.Repeat("a", 100)
for i := 0; i < 41; i++ {
- name := strings.Repeat("a", 100)
-
- err = Mkdir(name, 0755)
- if err != nil {
+ if err := Mkdir(name, 0755); err != nil {
t.Fatalf("Could not mkdir %s: %s", name, err)
}
-
- err = Chdir(name)
- if err != nil {
+ if err := Chdir(name); err != nil {
t.Fatalf("Could not chdir %s: %s", name, err)
}
}
- err = Chdir(prevDir)
+ // Chdir out of startPath before attempting to remove it,
+ // otherwise RemoveAll fails on aix, illumos and solaris.
+ err := Chdir(filepath.Join(startPath, ".."))
if err != nil {
- t.Fatalf("Could not chdir %s: %s", prevDir, err)
+ t.Fatalf("Could not chdir: %s", err)
}
err = RemoveAll(startPath)