testutil: If testing.T is nil panic with error (#4725)
This commit is contained in:
parent
e2fa2b133b
commit
02e5dc2b45
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue