Not sure when Golang added the -args option to Tests. But this now works:
$ go test -cover -v -run TestEventsTableTests -args -v 3 -logtostderr
true
The -args parameter allows you to pass in package-level flags into the
binary and test package to run.
For example, the glog logging package has options for -v and -logtostderr.
Previously we had to jump through lots of hoops to get glog logging in
tests. But now, we can just use -args and pass in any parameters we want.
Baked into Makefiles, it's solid in most of the projects I use it in.
On Monday, August 17, 2015 at 1:24:32 PM UTC-4, Sean Russell wrote:
>
> Hi,
>
> I've encountered a situation for which I have so far been unable to think
> of a solution. While the issue itself is a problem, it demonstrates a
> troublesome use case, and I'm interested in the recommended solution. If
> there's a thread that can be referenced that discusses this use case, feel
> free to point me at it; my search queries in the group failed to identify
> such a discussion.
>
> I use, and like, namsral/flag library <https://github.com/namsral/flag>.
> It's a drop-in replacement for the standard flag library, but provides
> support for pulling flag options from environment variables: it is simple
> and low impact. What I've seen is an interaction with some libraries that
> reference the standard library; fvbock/endless
> <http://github.com/fvbock/endless> (a zero-downtime restarts library) is
> an example; it defines flags in init()
> <https://github.com/fvbock/endless/blob/master/endless.go#L47> which it
> uses for process behavior control. It does this by calling flag.Parse()
> in a constructor
> <https://github.com/fvbock/endless/blob/master/endless.go#L81> and
> dealing with the flags.
>
> The problem is that namsral/flag's flag set and the default library's
> flag set are disjoint, meaning that any call to Parse() on either library
> (which obviously share the same input) is illegal. In other words, any
> os.Args passed in that are legal for namsral/flag will be illegal for the
> default flag library, which both (by default) reference the same input.
>
> Is this a unique situation? Is endless violating some unspoken
> best-practice -- or is namsral/flag? If neither of them are violating
> best practices, then what is the solution for this situation?
>
> Thanks,
>
> --- SER
>
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.