commit | 9587390b6065758f9a7c1610bfd0ac503a6328a6 | [log] [tgz] |
---|---|---|
author | Todd Wang <toddw@google.com> | Fri May 22 14:21:30 2015 -0700 |
committer | Todd Wang <toddw@google.com> | Fri May 22 14:21:32 2015 -0700 |
tree | 3d54fd30353dd0063f02cfcc476e9ca39d96e672 | |
parent | 06c85efe016e08d07909526dd716d3aa8eeef267 [diff] |
ref: 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: 3/5 Change-Id: I6442c6959a4cb27fc1515f6ea14a4018ceb9f6b8
This repository contains a reference implementation of the Vanadium APIs.
Unlike the APIs in https://github.com/vanadium/go.v23, which promises to provide backward compatibility this repository makes no such promises.