summaryrefslogtreecommitdiff
path: root/src/pkg/os/path_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/os/path_test.go')
-rw-r--r--src/pkg/os/path_test.go56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/pkg/os/path_test.go b/src/pkg/os/path_test.go
index 9b01bd5b6..fcd4bac54 100644
--- a/src/pkg/os/path_test.go
+++ b/src/pkg/os/path_test.go
@@ -5,38 +5,38 @@
package os_test
import (
- . "os";
- "testing";
+ . "os"
+ "testing"
)
func TestMkdirAll(t *testing.T) {
// Create new dir, in _obj so it will get
// cleaned up by make if not by us.
- path := "_obj/_TestMkdirAll_/dir/./dir2";
- err := MkdirAll(path, 0777);
+ path := "_obj/_TestMkdirAll_/dir/./dir2"
+ err := MkdirAll(path, 0777)
if err != nil {
t.Fatalf("MkdirAll %q: %s", path, err)
}
// Already exists, should succeed.
- err = MkdirAll(path, 0777);
+ err = MkdirAll(path, 0777)
if err != nil {
t.Fatalf("MkdirAll %q (second time): %s", path, err)
}
// Make file.
- fpath := path + "/file";
- _, err = Open(fpath, O_WRONLY|O_CREAT, 0666);
+ fpath := path + "/file"
+ _, err = Open(fpath, O_WRONLY|O_CREAT, 0666)
if err != nil {
t.Fatalf("create %q: %s", fpath, err)
}
// Can't make directory named after file.
- err = MkdirAll(fpath, 0777);
+ err = MkdirAll(fpath, 0777)
if err == nil {
t.Fatalf("MkdirAll %q: no error")
}
- perr, ok := err.(*PathError);
+ perr, ok := err.(*PathError)
if !ok {
t.Fatalf("MkdirAll %q returned %T, not *PathError", fpath, err)
}
@@ -45,12 +45,12 @@ func TestMkdirAll(t *testing.T) {
}
// Can't make subdirectory of file.
- ffpath := fpath + "/subdir";
- err = MkdirAll(ffpath, 0777);
+ ffpath := fpath + "/subdir"
+ err = MkdirAll(ffpath, 0777)
if err == nil {
t.Fatalf("MkdirAll %q: no error")
}
- perr, ok = err.(*PathError);
+ perr, ok = err.(*PathError)
if !ok {
t.Fatalf("MkdirAll %q returned %T, not *PathError", ffpath, err)
}
@@ -58,24 +58,24 @@ func TestMkdirAll(t *testing.T) {
t.Fatalf("MkdirAll %q returned wrong error path: %q not %q", ffpath, perr.Path, fpath)
}
- RemoveAll("_obj/_TestMkdirAll_");
+ RemoveAll("_obj/_TestMkdirAll_")
}
func TestRemoveAll(t *testing.T) {
// Work directory.
- path := "_obj/_TestRemoveAll_";
- fpath := path + "/file";
- dpath := path + "/dir";
+ path := "_obj/_TestRemoveAll_"
+ fpath := path + "/file"
+ dpath := path + "/dir"
// Make directory with 1 file and remove.
if err := MkdirAll(path, 0777); err != nil {
t.Fatalf("MkdirAll %q: %s", path, err)
}
- fd, err := Open(fpath, O_WRONLY|O_CREAT, 0666);
+ fd, err := Open(fpath, O_WRONLY|O_CREAT, 0666)
if err != nil {
t.Fatalf("create %q: %s", fpath, err)
}
- fd.Close();
+ fd.Close()
if err = RemoveAll(path); err != nil {
t.Fatalf("RemoveAll %q (first): %s", path, err)
}
@@ -87,16 +87,16 @@ func TestRemoveAll(t *testing.T) {
if err = MkdirAll(dpath, 0777); err != nil {
t.Fatalf("MkdirAll %q: %s", dpath, err)
}
- fd, err = Open(fpath, O_WRONLY|O_CREAT, 0666);
+ fd, err = Open(fpath, O_WRONLY|O_CREAT, 0666)
if err != nil {
t.Fatalf("create %q: %s", fpath, err)
}
- fd.Close();
- fd, err = Open(dpath+"/file", O_WRONLY|O_CREAT, 0666);
+ fd.Close()
+ fd, err = Open(dpath+"/file", O_WRONLY|O_CREAT, 0666)
if err != nil {
t.Fatalf("create %q: %s", fpath, err)
}
- fd.Close();
+ fd.Close()
if err = RemoveAll(path); err != nil {
t.Fatalf("RemoveAll %q (second): %s", path, err)
}
@@ -104,30 +104,30 @@ func TestRemoveAll(t *testing.T) {
t.Fatalf("Lstat %q succeeded after RemoveAll (second)", path)
}
- if Getuid() != 0 { // Test fails as root
+ if Getuid() != 0 { // Test fails as root
// Make directory with file and subdirectory and trigger error.
if err = MkdirAll(dpath, 0777); err != nil {
t.Fatalf("MkdirAll %q: %s", dpath, err)
}
for _, s := range []string{fpath, dpath + "/file1", path + "/zzz"} {
- fd, err = Open(s, O_WRONLY|O_CREAT, 0666);
+ fd, err = Open(s, O_WRONLY|O_CREAT, 0666)
if err != nil {
t.Fatalf("create %q: %s", s, err)
}
- fd.Close();
+ fd.Close()
}
if err = Chmod(dpath, 0); err != nil {
t.Fatalf("Chmod %q 0: %s", dpath, err)
}
if err = RemoveAll(path); err == nil {
- _, err := Lstat(path);
+ _, err := Lstat(path)
if err == nil {
t.Errorf("Can lstat %q after supposed RemoveAll", path)
}
- t.Fatalf("RemoveAll %q succeeded with chmod 0 subdirectory", path, err);
+ t.Fatalf("RemoveAll %q succeeded with chmod 0 subdirectory", path, err)
}
- perr, ok := err.(*PathError);
+ perr, ok := err.(*PathError)
if !ok {
t.Fatalf("RemoveAll %q returned %T not *PathError", path, err)
}