• Caleb Spare's avatar
    testing: delay flag registration; move to an Init function · fbc6a972
    Caleb Spare authored
    Any code that imports the testing package forces the testing flags to be
    defined, even in non-test binaries. People work around this today by
    defining a copy of the testing.TB interface just to avoid importing
    testing.
    
    Fix this by moving flag registration into a new function, testing.Init.
    Delay calling Init until the testing binary begins to run, in
    testing.MainStart.
    
    Init is exported for cases where users need the testing flags to be
    defined outside of a "go test" context. In particular, this may be
    needed where testing.Benchmark is called outside of a test.
    
    Fixes #21051
    
    Change-Id: Ib7e02459e693c26ae1ba71bbae7d455a91118ee3
    Reviewed-on: https://go-review.googlesource.com/c/go/+/173722Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    fbc6a972
Name
Last commit
Last update
..
main.go Loading commit data...
pkg.go Loading commit data...