aboutsummaryrefslogtreecommitdiff
path: root/tests/test_helpers
diff options
context:
space:
mode:
authorJakob Unterwurzacher2020-08-15 15:39:08 +0200
committerJakob Unterwurzacher2020-08-15 15:39:08 +0200
commitf270135c1614843f43a9df0e68b6e3fa556b6774 (patch)
tree2330d738e7a4eb78e8548579289fca0ce695bcb8 /tests/test_helpers
parent1ea1b179c23fe37c2f2da24e70e18dfa4ca1feff (diff)
test_helper: VerifyExistence: don't panic
Instead bubble up the error to the testing object.
Diffstat (limited to 'tests/test_helpers')
-rw-r--r--tests/test_helpers/helpers.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/test_helpers/helpers.go b/tests/test_helpers/helpers.go
index 37c82c1..6119065 100644
--- a/tests/test_helpers/helpers.go
+++ b/tests/test_helpers/helpers.go
@@ -289,7 +289,8 @@ func TestRename(t *testing.T, plainDir string) {
// VerifyExistence checks in 3 ways that "path" exists:
// stat, open, readdir. Returns true if the path exists, false otherwise.
// Panics if the result is inconsistent.
-func VerifyExistence(path string) bool {
+func VerifyExistence(t *testing.T, path string) bool {
+ t.Helper()
// Check if file can be stat()ed
stat := true
fi, err := os.Stat(path)
@@ -309,12 +310,12 @@ func VerifyExistence(path string) bool {
name := filepath.Base(path)
d, err := os.Open(dir)
if err != nil && open == true {
- log.Panicf("we can open the file but not the parent dir!? err=%v", err)
+ t.Errorf("VerifyExistence: we can open the file but not the parent dir!? err=%v", err)
} else if err == nil {
defer d.Close()
listing, err := d.Readdirnames(0)
if stat && fi.IsDir() && err != nil {
- log.Panicf("It's a directory, but readdirnames failed: %v", err)
+ t.Errorf("VerifyExistence: It's a directory, but readdirnames failed: %v", err)
}
for _, entry := range listing {
if entry == name {
@@ -326,7 +327,7 @@ func VerifyExistence(path string) bool {
if stat == open && open == readdir {
return stat
}
- log.Panicf("inconsistent result on %q: stat=%v open=%v readdir=%v, path=%q", name, stat, open, readdir, path)
+ t.Errorf("VerifyExistence: inconsistent result on %q: stat=%v open=%v readdir=%v, path=%q", name, stat, open, readdir, path)
return false
}