github.com/prysmaticlabs/prysm@v1.4.4/cmd/beacon-chain/usage_test.go (about) 1 package main 2 3 import ( 4 "testing" 5 6 "github.com/prysmaticlabs/prysm/shared/featureconfig" 7 "github.com/urfave/cli/v2" 8 ) 9 10 func TestAllFlagsExistInHelp(t *testing.T) { 11 // If this test is failing, it is because you've recently added/removed a 12 // flag in beacon chain main.go, but did not add/remove it to the usage.go 13 // flag grouping (appHelpFlagGroups). 14 15 var helpFlags []cli.Flag 16 for _, group := range appHelpFlagGroups { 17 helpFlags = append(helpFlags, group.Flags...) 18 } 19 helpFlags = featureconfig.ActiveFlags(helpFlags) 20 appFlags = featureconfig.ActiveFlags(appFlags) 21 22 for _, flag := range appFlags { 23 if !doesFlagExist(flag, helpFlags) { 24 t.Errorf("Flag %s does not exist in help/usage flags.", flag.Names()[0]) 25 } 26 } 27 28 for _, flag := range helpFlags { 29 if !doesFlagExist(flag, appFlags) { 30 t.Errorf("Flag %s does not exist in main.go, "+ 31 "but exists in help flags", flag.Names()[0]) 32 } 33 } 34 } 35 36 func doesFlagExist(flag cli.Flag, flags []cli.Flag) bool { 37 for _, f := range flags { 38 if f.String() == flag.String() { 39 return true 40 } 41 } 42 43 return false 44 }