I wanted to testing the output of a command and I just check that Go does very easy. I know that could testing functions of a command but not the "full command" through main().
This is really cool. To pass it the argument that you would use in the command line, insert them in os.Args, and then you already run main()
func init() {
os.Args = []string{"def2go", "-s", "linux", "-p", "foo", "testdata/ioctls.h"}
}
func Test(t *testing.T) {
main()
}
And it runs like if were done from command line. The only problem is that it can not be used the example functions to checking whether the ouput is like I was expecting.
Is there any technical issue for that the example functions can not be run in commands?