aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-11-26 15:17:15 +0100
committerJakob Unterwurzacher2016-11-26 15:20:54 +0100
commit3f5c48e0585f6fe0782aded541e42879eb570e69 (patch)
treebbec927ead78447195a719134e060842c1c46ec2 /tests
parenta6006c0d2bcef66cc3c6a6bb22de747b9be874c1 (diff)
tests: don't call t.Fatal in checkExampleFS
Calling t.Fatal means that the parent test has no chance to clean up.
Diffstat (limited to 'tests')
-rw-r--r--tests/example_filesystems/example_test_helpers.go10
-rw-r--r--tests/test_helpers/helpers.go32
2 files changed, 26 insertions, 16 deletions
diff --git a/tests/example_filesystems/example_test_helpers.go b/tests/example_filesystems/example_test_helpers.go
index 615e4c1..d89b35f 100644
--- a/tests/example_filesystems/example_test_helpers.go
+++ b/tests/example_filesystems/example_test_helpers.go
@@ -15,7 +15,8 @@ func checkExampleFS(t *testing.T, dir string, rw bool) {
statusFile := filepath.Join(dir, "status.txt")
contentBytes, err := ioutil.ReadFile(statusFile)
if err != nil {
- t.Fatal(err)
+ t.Error(err)
+ return
}
content := string(contentBytes)
if content != statusTxtContent {
@@ -25,7 +26,8 @@ func checkExampleFS(t *testing.T, dir string, rw bool) {
symlink := filepath.Join(dir, "rel")
target, err := os.Readlink(symlink)
if err != nil {
- t.Fatal(err)
+ t.Error(err)
+ return
}
if target != "status.txt" {
t.Errorf("Unexpected link target: %s\n", target)
@@ -34,12 +36,12 @@ func checkExampleFS(t *testing.T, dir string, rw bool) {
symlink = filepath.Join(dir, "abs")
target, err = os.Readlink(symlink)
if err != nil {
- t.Fatal(err)
+ t.Error(err)
+ return
}
if target != "/a/b/c/d" {
t.Errorf("Unexpected link target: %s\n", target)
}
-
if rw {
// Test directory operations
test_helpers.TestRename(t, dir)
diff --git a/tests/test_helpers/helpers.go b/tests/test_helpers/helpers.go
index 90b00b6..01ef319 100644
--- a/tests/test_helpers/helpers.go
+++ b/tests/test_helpers/helpers.go
@@ -227,20 +227,23 @@ func TestMkdirRmdir(t *testing.T, plainDir string) {
dir := plainDir + "/dir1"
err := os.Mkdir(dir, 0777)
if err != nil {
- t.Fatal(err)
+ t.Error(err)
+ return
}
err = syscall.Rmdir(dir)
if err != nil {
- t.Fatal(err)
+ t.Error(err)
+ return
}
-
// Removing a non-empty dir should fail with ENOTEMPTY
if os.Mkdir(dir, 0777) != nil {
- t.Fatal(err)
+ t.Error(err)
+ return
}
f, err := os.Create(dir + "/file")
if err != nil {
- t.Fatal(err)
+ t.Error(err)
+ return
}
f.Close()
err = syscall.Rmdir(dir)
@@ -249,23 +252,26 @@ func TestMkdirRmdir(t *testing.T, plainDir string) {
t.Errorf("Should have gotten ENOTEMPTY, go %v", errno)
}
if syscall.Unlink(dir+"/file") != nil {
- t.Fatal(err)
+ t.Error(err)
+ return
}
if syscall.Rmdir(dir) != nil {
- t.Fatal(err)
+ t.Error(err)
+ return
}
-
// We should also be able to remove a directory we do not have permissions to
// read or write
err = os.Mkdir(dir, 0000)
if err != nil {
- t.Fatal(err)
+ t.Error(err)
+ return
}
err = syscall.Rmdir(dir)
if err != nil {
// Make sure the directory can cleaned up by the next test run
os.Chmod(dir, 0700)
- t.Fatal(err)
+ t.Error(err)
+ return
}
}
@@ -275,11 +281,13 @@ func TestRename(t *testing.T, plainDir string) {
file2 := plainDir + "/rename2"
err := ioutil.WriteFile(file1, []byte("content"), 0777)
if err != nil {
- t.Fatal(err)
+ t.Error(err)
+ return
}
err = syscall.Rename(file1, file2)
if err != nil {
- t.Fatal(err)
+ t.Error(err)
+ return
}
syscall.Unlink(file2)
}