prysm-pulse/beacon-chain/usage_test.go

45 lines
1.0 KiB
Go
Raw Normal View History

2019-06-02 15:33:44 +00:00
package main
import (
"testing"
"github.com/prysmaticlabs/prysm/shared/featureconfig"
"gopkg.in/urfave/cli.v2"
2019-06-02 15:33:44 +00:00
)
func TestAllFlagsExistInHelp(t *testing.T) {
// If this test is failing, it is because you've recently added/removed a
// flag in beacon chain main.go, but did not add/remove it to the usage.go
// flag grouping (appHelpFlagGroups).
var helpFlags []cli.Flag
for _, group := range appHelpFlagGroups {
helpFlags = append(helpFlags, group.Flags...)
}
helpFlags = featureconfig.ActiveFlags(helpFlags)
appFlags = featureconfig.ActiveFlags(appFlags)
2019-06-02 15:33:44 +00:00
for _, flag := range appFlags {
if !doesFlagExist(flag, helpFlags) {
t.Errorf("Flag %s does not exist in help/usage flags.", flag.Names()[0])
2019-06-02 15:33:44 +00:00
}
}
for _, flag := range helpFlags {
if !doesFlagExist(flag, appFlags) {
t.Errorf("Flag %s does not exist in main.go, "+
"but exists in help flags", flag.Names()[0])
2019-06-02 15:33:44 +00:00
}
}
}
func doesFlagExist(flag cli.Flag, flags []cli.Flag) bool {
for _, f := range flags {
if f.String() == flag.String() {
2019-06-02 15:33:44 +00:00
return true
}
}
return false
}