Merge pull request #82742 from whypro/flagparse

Move flag.Parse() from init() to TestMain()
This commit is contained in:
Kubernetes Prow Robot 2019-09-20 00:09:12 -07:00 committed by GitHub
commit 895642f9c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 5 deletions

View File

@ -69,7 +69,7 @@ func handleFlags() {
flag.Parse()
}
func init() {
func TestMain(m *testing.M) {
// Register test flags, then parse flags.
handleFlags()
@ -105,9 +105,6 @@ func init() {
AssetNames: generated.AssetNames,
})
}
func TestMain(m *testing.M) {
rand.Seed(time.Now().UnixNano())
os.Exit(m.Run())
}

View File

@ -45,11 +45,11 @@ func init() {
// Set this to false to undo util/logs.go settings it to true. Prevents cadvisor log spam.
// Remove this once util/logs.go stops setting the flag to true.
flag.Set("logtostderr", "false")
flag.Parse()
}
// TODO: Should we write an e2e test for this?
func main() {
flag.Parse()
o := strings.Split(*checkFlag, ",")
errs := check(o...)
if len(errs) > 0 {