-
Notifications
You must be signed in to change notification settings - Fork 697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpf2go: argument parsing unit test #1054
Conversation
} | ||
} | ||
|
||
b2g.strip, err = exec.LookPath(b2g.strip) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving LookupPath
out of parseArgs
so that unit tests can pass arbitrary values in -strip
flag.
ab6ce20
to
d8c68d5
Compare
d8c68d5
to
9a81965
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks for the quick turn around!
cmd/bpf2go/main.go
Outdated
makeBase string | ||
} | ||
|
||
func (b2g *bpf2go) parseArgs(args []string) (err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: my preference is to have constructor like function as much as possible. How would you feel about newB2G(stdout io.Writer, pkg, outputDir string, args []string) (*b2g, error)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
9a81965
to
5091cf1
Compare
} | ||
|
||
input := args[1] | ||
if _, err := os.Stat(input); os.IsNotExist(err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving os.Stat
out of newB2G
so that unit tests can pass arbitrary values.
Signed-off-by: Nick Zavaritsky <mejedi@gmail.com>
5091cf1
to
3d8c466
Compare
Fixed a nit and rebased, thanks for refactoring this! |
@lmb thank you for the reviews! Any chance this could be merged? |
Enable unit tests for argument parsing in
bpf2go
. This is in preparation for enabling bpf2go to take some arguments from the environment.The patch moves argument parsing from
run
into a separate function.