pingcap / failpoint

An implementation of failpoints for Golang.
Apache License 2.0
817 stars 63 forks source link

code: auto extend failpoint name with package name #8

Closed lonng closed 5 years ago

lonng commented 5 years ago

Signed-off-by: Lonng chris@lonng.org

What problem does this PR solve?

Will auto extend failpoint name with package name. For example,

pacakge ddl // which contains in project github.com/pingcap/tidb

func createTable() {
    failpoint.Inject("createTableErr"), func() {...})
}

The name will auto extend to github.com/pingcap/tidb/ddl/createTableErr

What is changed and how it works?

Rewrite some rules

Check List

Tests

Side effects

N/A

Related changes

N/A

lonng commented 5 years ago

PTAL @winkyao @kennytm @amyangfei

codecov[bot] commented 5 years ago

Codecov Report

Merging #8 into master will increase coverage by 0.8293%. The diff coverage is 70.8333%.

@@               Coverage Diff                @@
##             master         #8        +/-   ##
================================================
+ Coverage   54.6599%   55.4892%   +0.8293%     
================================================
  Files             8          8                
  Lines           794        838        +44     
================================================
+ Hits            434        465        +31     
- Misses          275        284         +9     
- Partials         85         89         +4
kennytm commented 5 years ago

I'd like to confirm, is there no way to obtain the package name during rewrite? (the github.com/pingcap/tidb part should be obtainable from go.mod, and the ddl part should be available from the source's package declaration)

lonng commented 5 years ago

I'd like to confirm, is there no way to obtain the package name during rewrite? (the github.com/pingcap/tidb part should be obtainable from go.mod, and the ddl part should be available from the source's package declaration)

We can get the github.com/pingcap/tidb in go.mod if it exists, and get ddl part in the package declaration. But there is not all repository use go modules. But I can get the package path in init function to improve performance.

kennytm commented 5 years ago

But there is not all repository use go modules.

Though if the repo is not using go modules, it should be placed in $GOPATH/src/github.com/pingcap/tidb.