}
func TestStatDirWithTrailingSlash(t *testing.T) {
- // Create new dir, in _obj so it will get
+ // Create new dir, in _test so it will get
// cleaned up by make if not by us.
- path := "_obj/_TestStatDirWithSlash_"
+ path := "_test/_TestStatDirWithSlash_"
err := MkdirAll(path, 0777)
if err != nil {
t.Fatalf("MkdirAll %q: %s", path, err)
}
+ defer RemoveAll(path)
// Stat of path should succeed.
_, err = Stat(path)
if err != nil {
t.Fatal("stat failed:", err)
}
-
- RemoveAll("_obj/_TestMkdirAll_")
}
import (
. "os"
"testing"
+ "runtime"
"syscall"
)
func TestMkdirAll(t *testing.T) {
- // Create new dir, in _obj so it will get
+ // Create new dir, in _test so it will get
// cleaned up by make if not by us.
- path := "_obj/_TestMkdirAll_/dir/./dir2"
+ path := "_test/_TestMkdirAll_/dir/./dir2"
err := MkdirAll(path, 0777)
if err != nil {
t.Fatalf("MkdirAll %q: %s", path, err)
}
+ defer RemoveAll("_test/_TestMkdirAll_")
// Already exists, should succeed.
err = MkdirAll(path, 0777)
if perr.Path != fpath {
t.Fatalf("MkdirAll %q returned wrong error path: %q not %q", ffpath, perr.Path, fpath)
}
-
- RemoveAll("_obj/_TestMkdirAll_")
}
func TestRemoveAll(t *testing.T) {
// Work directory.
- path := "_obj/_TestRemoveAll_"
+ path := "_test/_TestRemoveAll_"
fpath := path + "/file"
dpath := path + "/dir"
t.Fatalf("Lstat %q succeeded after RemoveAll (final)", path)
}
}
+
+func TestMkdirAllWithSymlink(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Log("Skipping test: symlinks don't exist under Windows")
+ return
+ }
+
+ err := Mkdir("_test/dir", 0755)
+ if err != nil {
+ t.Fatal(`Mkdir "_test/dir":`, err)
+ }
+ defer RemoveAll("_test/dir")
+
+ err = Symlink("dir", "_test/link")
+ if err != nil {
+ t.Fatal(`Symlink "dir", "_test/link":`, err)
+ }
+ defer RemoveAll("_test/link")
+
+ path := "_test/link/foo"
+ err = MkdirAll(path, 0755)
+ if err != nil {
+ t.Errorf("MkdirAll %q: %s", path, err)
+ }
+}