Neded for: https://vanadium-review.googlesource.com/#/c/4332/
MultiPart: 3/3

Change-Id: Ieac0e81306d38b7a131c0af21e35d359faff37ae
diff --git a/lib/modules/registry.go b/lib/modules/registry.go
index f473d14..555c1a2 100644
--- a/lib/modules/registry.go
+++ b/lib/modules/registry.go
@@ -99,6 +99,27 @@
 	return append(newEnv, shellEntryPoint+"="+name)
 }
 
+// Dispatch will execute the requested subprocess command from a within a
+// a subprocess. It will return without an error if it is executed by a
+// process that does not specify an entry point in its environment.
+//
+// func main() {
+//     if modules.IsModulesProcess() {
+//         if err := modules.Dispatch(); err != nil {
+//             panic("error")
+//         }
+//         eturn
+//     }
+//     parent code...
+//
+func Dispatch() error {
+	if !IsModulesProcess() {
+		return nil
+	}
+	return registry.dispatch()
+}
+
+// TODO(cnicolaou): delete this in a subsequent CL.
 // DispatchInTest will execute the requested subproccess command from within
 // a unit test run as a subprocess.
 func DispatchInTest() {
@@ -111,30 +132,6 @@
 	os.Exit(0)
 }
 
-// Dispatch will execute the requested subprocess command from a within a
-// a subprocess that is not a unit test. It will return without an error
-// if it is executed by a process that does not specify an entry point
-// in its environment.
-//
-// func main() {
-//     if modules.IsModulesProcess() {
-//         if err := modules.Dispatch(); err != nil {
-//             panic("error")
-//          }
-//          return
-//      }
-//      parent code...
-//
-func Dispatch() error {
-	if !IsModulesProcess() {
-		return nil
-	}
-	if IsTestHelperProcess() {
-		return fmt.Errorf("use DispatchInTest in unittests")
-	}
-	return registry.dispatch()
-}
-
 // DispatchAndExit is like Dispatch except that it will call os.Exit(0)
 // when executed within a child process and the command succeeds, or panic
 // on encountering an error.
diff --git a/services/identity/identityd/v23_test.go b/services/identity/identityd/v23_test.go
index 72afa15..b0ea5cb 100644
--- a/services/identity/identityd/v23_test.go
+++ b/services/identity/identityd/v23_test.go
@@ -13,7 +13,6 @@
 	cleanup := v23tests.UseSharedBinDir()
 	r := m.Run()
 	cleanup()
-	// TODO(cnicolaou): call modules.Dispatch and remove the need for TestHelperProcess
 	os.Exit(r)
 }
 
diff --git a/services/mgmt/application/applicationd/v23_test.go b/services/mgmt/application/applicationd/v23_test.go
index 9e43b89..f3e858c 100644
--- a/services/mgmt/application/applicationd/v23_test.go
+++ b/services/mgmt/application/applicationd/v23_test.go
@@ -13,7 +13,6 @@
 	cleanup := v23tests.UseSharedBinDir()
 	r := m.Run()
 	cleanup()
-	// TODO(cnicolaou): call modules.Dispatch and remove the need for TestHelperProcess
 	os.Exit(r)
 }
 
diff --git a/services/mgmt/binary/binaryd/v23_test.go b/services/mgmt/binary/binaryd/v23_test.go
index a74c88b..eec6864 100644
--- a/services/mgmt/binary/binaryd/v23_test.go
+++ b/services/mgmt/binary/binaryd/v23_test.go
@@ -13,7 +13,6 @@
 	cleanup := v23tests.UseSharedBinDir()
 	r := m.Run()
 	cleanup()
-	// TODO(cnicolaou): call modules.Dispatch and remove the need for TestHelperProcess
 	os.Exit(r)
 }
 
diff --git a/services/mgmt/build/buildd/v23_test.go b/services/mgmt/build/buildd/v23_test.go
index 6c1a4c8..8ed558e 100644
--- a/services/mgmt/build/buildd/v23_test.go
+++ b/services/mgmt/build/buildd/v23_test.go
@@ -13,7 +13,6 @@
 	cleanup := v23tests.UseSharedBinDir()
 	r := m.Run()
 	cleanup()
-	// TODO(cnicolaou): call modules.Dispatch and remove the need for TestHelperProcess
 	os.Exit(r)
 }
 
diff --git a/services/mgmt/profile/profiled/v23_test.go b/services/mgmt/profile/profiled/v23_test.go
index 2917072..cb048e1 100644
--- a/services/mgmt/profile/profiled/v23_test.go
+++ b/services/mgmt/profile/profiled/v23_test.go
@@ -13,7 +13,6 @@
 	cleanup := v23tests.UseSharedBinDir()
 	r := m.Run()
 	cleanup()
-	// TODO(cnicolaou): call modules.Dispatch and remove the need for TestHelperProcess
 	os.Exit(r)
 }
 
diff --git a/services/mounttable/mounttabled/v23_test.go b/services/mounttable/mounttabled/v23_test.go
index 7cfad44..a464bad 100644
--- a/services/mounttable/mounttabled/v23_test.go
+++ b/services/mounttable/mounttabled/v23_test.go
@@ -13,7 +13,6 @@
 	cleanup := v23tests.UseSharedBinDir()
 	r := m.Run()
 	cleanup()
-	// TODO(cnicolaou): call modules.Dispatch and remove the need for TestHelperProcess
 	os.Exit(r)
 }
 
diff --git a/tools/debug/v23_test.go b/tools/debug/v23_test.go
index 0dc059b..451bd67 100644
--- a/tools/debug/v23_test.go
+++ b/tools/debug/v23_test.go
@@ -13,7 +13,6 @@
 	cleanup := v23tests.UseSharedBinDir()
 	r := m.Run()
 	cleanup()
-	// TODO(cnicolaou): call modules.Dispatch and remove the need for TestHelperProcess
 	os.Exit(r)
 }
 
diff --git a/tools/naming/simulator/v23_test.go b/tools/naming/simulator/v23_test.go
index 9c42af4..043c638 100644
--- a/tools/naming/simulator/v23_test.go
+++ b/tools/naming/simulator/v23_test.go
@@ -13,7 +13,6 @@
 	cleanup := v23tests.UseSharedBinDir()
 	r := m.Run()
 	cleanup()
-	// TODO(cnicolaou): call modules.Dispatch and remove the need for TestHelperProcess
 	os.Exit(r)
 }
 
diff --git a/tools/principal/v23_test.go b/tools/principal/v23_test.go
index 806ef4d..665f5c3 100644
--- a/tools/principal/v23_test.go
+++ b/tools/principal/v23_test.go
@@ -13,7 +13,6 @@
 	cleanup := v23tests.UseSharedBinDir()
 	r := m.Run()
 	cleanup()
-	// TODO(cnicolaou): call modules.Dispatch and remove the need for TestHelperProcess
 	os.Exit(r)
 }
 
diff --git a/tools/vrun/internal/v23_test.go b/tools/vrun/internal/v23_test.go
index ebbc180..b214a3e 100644
--- a/tools/vrun/internal/v23_test.go
+++ b/tools/vrun/internal/v23_test.go
@@ -13,7 +13,6 @@
 	cleanup := v23tests.UseSharedBinDir()
 	r := m.Run()
 	cleanup()
-	// TODO(cnicolaou): call modules.Dispatch and remove the need for TestHelperProcess
 	os.Exit(r)
 }