ref/lib/flags, ref/test: make it possible to set new default values.
Ideally it should be possible for test.Init to set 'safe' defaults
for use in tests - e.g. not to use ns.dev.v.io etc. This is a little
more complicated because of the initialization order between profiles,
the runtime and flags. The flag sets must be created by an init
function as per usual, however, this is also when default values
are read (this is so that --help can display the correct defaults).
This change allows for defaults (via the SetDefaults functions)
to be changed outside of init functions but before flags.Parse is
called.
Fix up the mounttable cmd test to not rely on ns.dev.v.io.
Change-Id: Icc166fff04bb5a263981231a0ace064d5beacc74
diff --git a/test/init.go b/test/init.go
index 04d1ffd..f3cc8c2 100644
--- a/test/init.go
+++ b/test/init.go
@@ -11,6 +11,7 @@
"v.io/x/lib/vlog"
+ "v.io/x/ref/lib/flags"
"v.io/x/ref/test/testutil"
)
@@ -44,6 +45,9 @@
// if GOMAXPROCS is not set in the environment.
runtime.GOMAXPROCS(runtime.NumCPU())
}
+ flags.SetDefaultProtocol("tcp")
+ flags.SetDefaultHostPort("127.0.0.1:0")
+ flags.SetDefaultNamespaceRoot("/127.0.0.1:8101")
// At this point all of the flags that we're going to use for
// tests must be defined.
// This will be the case if this is called from the init()