From 0934940f4e2a41823546ba6e0657c49ba49219f4 Mon Sep 17 00:00:00 2001 From: James Hartig Date: Fri, 26 Oct 2018 15:13:40 -0400 Subject: [PATCH] testutil: If testing.T is nil panic with error (#4725) --- testutil/io.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/testutil/io.go b/testutil/io.go index 7d0ca6effc..77041d47d8 100644 --- a/testutil/io.go +++ b/testutil/io.go @@ -39,6 +39,9 @@ func TempDir(t *testing.T, name string) string { name = strings.Replace(name, "/", "_", -1) d, err := ioutil.TempDir(tmpdir, name) if err != nil { + if t == nil { + panic(err) + } t.Fatalf("err: %s", err) } return d @@ -55,6 +58,9 @@ func TempFile(t *testing.T, name string) *os.File { } f, err := ioutil.TempFile(tmpdir, name) if err != nil { + if t == nil { + panic(err) + } t.Fatalf("err: %s", err) } return f