- // NOTE: This is not guaranteed to work according to reflect's
- // documentation but seems to work reliable for normal
- // functions.
- fn := runtime.FuncForPC(reflect.ValueOf(f).Pointer())
- name := fn.Name()
- name = name[strings.LastIndex(name, ".")+1:]
-
- t.Run(name, func(t *testing.T) {
- // Preparation & cleanup
- for _, p := range cleanup {
- err := os.Remove(p)
- if err != nil && !os.IsNotExist(err) {
- t.Fatal(err)
- }
- // Remove the file at the end of this test
- // run, if it was created
- defer os.Remove(p)
+ // NOTE: This is not guaranteed to work according to reflect's
+ // documentation but seems to work reliable for normal functions.
+ fn := runtime.FuncForPC(reflect.ValueOf(f).Pointer())
+ name := fn.Name()
+ name = name[strings.LastIndex(name, ".")+1:]
+
+ t.Run(name, func(t *testing.T) {
+ // Preparation & cleanup
+ for _, p := range cleanup {
+ err := os.Remove(p)
+ if err != nil && !os.IsNotExist(err) {
+ t.Fatal(err)