lib: Change test/modules registration mechanism.

Previously modules registration and usage looked like this:

func foo(stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error {
...
}

func init() {
modules.RegisterChild("foo", "", foo)
}

func TestFoo(t *testing.T) {
sh, err := modules.NewShell(...)
h, err := sh.Start("foo", nil, ...)
...
}

The new modules registration and usage looks like this:

var foo = modules.Register(func(env *modules.Env, args ...string) error {
...
}, "foo")

func TestFoo(t *testing.T) {
sh, err := modules.NewShell(...)
h, err := sh.Start(nil, foo, ...)
...
}

The main change is that Register now returns a modules.Program,
which is typically captured in a global variable, and is used as
the argument to Shell.Start.  This makes it easy to write the
registration manually, and we also have a more obvious linkage
between program registration and the Start call through the
program variable, rather than using strings.

Since registration was annoying to write manually, we used to
have 'v23 test generate' detect the functions and automatically
add the modules.RegisterChild call.  With the new mechanism, the
registration is simple to write manually, so 'v23 test generate'
has been simplified to remove the detection logic.

In fact the Program returned by modules.Register now must be
captured, so that it can be passed to Shell.Start; this forces
the linkage between Register and Start to be obvious.

Also removed the modules Help mechanism, since it wasn't being
used, and has questionable utility.  In its place, added logic to
dump all registered programs when program lookups fail.

MultiPart: 2/5

Change-Id: I6d97bc3bc0b74003fb875231ea47a40216a3bac5
diff --git a/vlog/flags_test.go b/vlog/flags_test.go
index 6e9d3b6..37c73db 100644
--- a/vlog/flags_test.go
+++ b/vlog/flags_test.go
@@ -7,19 +7,17 @@
 import (
 	"flag"
 	"fmt"
-	"io"
 	"os"
 	"path/filepath"
 	"testing"
 
 	"v.io/x/lib/vlog"
-
 	"v.io/x/ref/test/modules"
 )
 
 //go:generate v23 test generate
 
-func child(stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error {
+var child = modules.Register(func(env *modules.Env, args ...string) error {
 	tmp := filepath.Join(os.TempDir(), "foo")
 	flag.Set("log_dir", tmp)
 	flag.Set("vmodule", "foo=2")
@@ -43,7 +41,7 @@
 		return fmt.Errorf("max_stack_buf_size unexpectedly set to %v", v)
 	}
 	return nil
-}
+}, "child")
 
 func TestFlags(t *testing.T) {
 	sh, err := modules.NewShell(nil, nil, testing.Verbose(), t)
@@ -51,7 +49,7 @@
 		t.Fatalf("unexpected error: %s", err)
 	}
 	defer sh.Cleanup(nil, nil)
-	h, err := sh.Start("child", nil)
+	h, err := sh.Start(nil, child)
 	if err != nil {
 		t.Fatalf("unexpected error: %v", err)
 	}
diff --git a/vlog/v23_test.go b/vlog/v23_test.go
index 129e96d..838b188 100644
--- a/vlog/v23_test.go
+++ b/vlog/v23_test.go
@@ -4,27 +4,19 @@
 
 // This file was auto-generated via go generate.
 // DO NOT UPDATE MANUALLY
+
 package vlog_test
 
-import "fmt"
-import "testing"
-import "os"
+import (
+	"os"
+	"testing"
 
-import "v.io/x/ref/test"
-import "v.io/x/ref/test/modules"
-
-func init() {
-	modules.RegisterChild("child", ``, child)
-}
+	"v.io/x/ref/test"
+	"v.io/x/ref/test/modules"
+)
 
 func TestMain(m *testing.M) {
 	test.Init()
-	if modules.IsModulesChildProcess() {
-		if err := modules.Dispatch(); err != nil {
-			fmt.Fprintf(os.Stderr, "modules.Dispatch failed: %v\n", err)
-			os.Exit(1)
-		}
-		return
-	}
+	modules.DispatchAndExitIfChild()
 	os.Exit(m.Run())
 }