veyron/lib/modules: Make modules parse flags using the veyron2.Init
flag parsing mechanism.
Now the user of modules need not call veyron2.Init to parse the flags,
whereas before the flags had to be parsed before calling dispatch.
The profiles can now use the flags passed to a subcommand whereas before
they could not.
Upcoming changes:
(1) Make the rest of the callers to testutil.Init use go1.4's TestMain to avoid
flags being parsed in init functions.
(2) Get rid of modules.DispatchInTest and use go1.4's TestMain instead.
Change-Id: I71e31929a674dfc11310d203aba452a69c10b2b2
diff --git a/lib/modules/modules_test.go b/lib/modules/modules_test.go
index 277fb2f..a5c989d 100644
--- a/lib/modules/modules_test.go
+++ b/lib/modules/modules_test.go
@@ -62,7 +62,7 @@
}
func PrintFromEnv(stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error {
- for _, a := range args[1:] {
+ for _, a := range args {
if v := env[a]; len(v) > 0 {
fmt.Fprintf(stdout, "%s\n", a+"="+v)
} else {
@@ -286,7 +286,7 @@
var stdoutBuf bytes.Buffer
var stderrBuf bytes.Buffer
sh.Cleanup(&stdoutBuf, &stderrBuf)
- stdoutOutput, stderrOutput := "stdout: "+command+"\n", "stderr: "+command+"\n"
+ var stdoutOutput, stderrOutput string
for _, a := range args {
stdoutOutput += fmt.Sprintf("stdout: %s\n", a)
stderrOutput += fmt.Sprintf("stderr: %s\n", a)