Skip to content

Commit

Permalink
check whether projectPath is directory
Browse files Browse the repository at this point in the history
  • Loading branch information
pdelewski committed Feb 6, 2023
1 parent 01ffca6 commit ee021aa
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions instrgen/driver/main.go
Expand Up @@ -96,11 +96,28 @@ func dumpRootFunctions(rootFunctions []alib.FuncDescriptor) {
}
}

func isDirectory(path string) (bool, error) {
fileInfo, err := os.Stat(path)
if err != nil {
return false, err
}

return fileInfo.IsDir(), err
}

// Parsing algorithm works as follows. It goes through all function
// decls and infer function bodies to find call to AutotelEntryPoint
// A parent function of this call will become root of instrumentation
// Each function call from this place will be instrumented automatically.
func executeCommand(command string, projectPath string, packagePattern string) error {
isDir, err := isDirectory(projectPath)
if !isDir {
_ = usage()
return errors.New("[path to go project] argument must be directory")
}
if err != nil {
return err
}
if command == "--inject" {
_, err := Prune(projectPath, packagePattern, false)
if err != nil {
Expand Down

0 comments on commit ee021aa

Please sign in to comment.