From 6bd2da89d3753a589a927517771922a0db76bb36 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Wed, 6 Dec 2017 23:03:37 +0100 Subject: tets_helpers: handle t=nil in InitFS The reverse tests call InitFS with t=nil. By calling panic we get a better error message instead of a generic nil pointer dereference. --- tests/test_helpers/helpers.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test_helpers/helpers.go b/tests/test_helpers/helpers.go index 9b81b45..778fd3a 100644 --- a/tests/test_helpers/helpers.go +++ b/tests/test_helpers/helpers.go @@ -7,6 +7,7 @@ import ( "encoding/json" "fmt" "io/ioutil" + "log" "net" "os" "os/exec" @@ -110,7 +111,11 @@ func ResetTmpDir(createDirIV bool) { func InitFS(t *testing.T, extraArgs ...string) string { dir, err := ioutil.TempDir(TmpDir, "") if err != nil { - t.Fatal(err) + if t != nil { + t.Fatal(err) + } else { + log.Panic(err) + } } args := []string{"-q", "-init", "-extpass", "echo test", "-scryptn=10"} args = append(args, extraArgs...) @@ -122,7 +127,11 @@ func InitFS(t *testing.T, extraArgs ...string) string { err = cmd.Run() if err != nil { - t.Fatalf("InitFS with args %v failed: %v", args, err) + if t != nil { + t.Fatalf("InitFS with args %v failed: %v", args, err) + } else { + log.Panic(err) + } } return dir -- cgit v1.2.3