Closed yechenyuyu closed 1 year ago
Add the package name of foo.go
before the failpoint label name when you call failpoint.Enable
will probably fix your problem.
$ cat test.go
package main
import "github.com/pingcap/failpoint"
func main() {
failpoint.Enable("main/testPanic", "return(true)")
if _, ok := failpoint.Eval(_curpkg_("testPanic")); ok {
panic("failpoint triggerd")
}
}
$ failpoint-ctl enable
$ go run ./
panic: failpoint triggerd
goroutine 1 [running]:
main.main()
/root/test-go/test.go:8 +0xe5
exit status 2
Closed as stale and answered.
Please provide a complete repro if the problem is still relevant.
I write this in foo.go:
and i run
failpoint-ctl enable
, code becomes this;then in foo_test.go ,i write my test code like this:
and it fails, and obviously the failpoint is not activated, can someone tell me why?