Documentation ¶
Index ¶
Constants ¶
const (
ExtendPkgName = "_curpkg_"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Restorer ¶
type Restorer struct {
// contains filtered or unexported fields
}
Restorer represents a manager to restore currentFile tree which has been modified by `failpoint-ctl enable`, e.g:
// ├── foo // │ ├── foo.go // │ └── foo.go__failpoint_stash__ // ├── bar // │ ├── bar.go // │ └── bar.go__failpoint_stash__ // └── foobar // ├── foobar.go // └── foobar.go__failpoint_stash__ // Which will be restored as below: // ├── foo // │ └── foo.go <- foo.go__failpoint_stash__ // ├── bar // │ └── bar.go <- bar.go__failpoint_stash__ // └── foobar // └── foobar.go <- foobar.go__failpoint_stash__
func NewRestorer ¶
NewRestorer returns a non-nil restorer which is used to clean the workspace of the specified path
type Rewriter ¶
type Rewriter struct {
// contains filtered or unexported fields
}
Rewriter represents a rewriting tool for converting the failpoint marker functions to corresponding statements in Golang. It will traverse the specified path and filter out files which do not have failpoint injection sites, and rewrite the remain files.
func NewRewriter ¶
NewRewriter returns a non-nil rewriter which is used to rewrite the specified path
func (*Rewriter) GetCurrentFile ¶
GetCurrentFile returns the current file which is being rewritten
func (*Rewriter) GetRewritten ¶
GetRewritten returns whether the rewriter has rewritten the file in a RewriteFile call.
func (*Rewriter) Rewrite ¶
Rewrite does the rewrite action for specified path. It contains the main steps:
1. Filter out failpoint binding files and files that have no suffix `.go` 2. Filter out files which have not imported failpoint package (implying no failpoints) 3. Parse file to `ast.File` and rewrite the AST 4. Create failpoint binding file (which contains `_curpkg_` function) if it does not exist 5. Rename original file to `original-file-name + __failpoint_stash__` 6. Replace original file content base on the new AST
func (*Rewriter) RewriteFile ¶
RewriteFile rewrites a single file
func (*Rewriter) SetAllowNotChecked ¶
SetAllowNotChecked sets whether the rewriter allows the file which does not import failpoint package.