2019-09-11 14:38:35 -04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-03-17 11:52:56 -07:00
|
|
|
"github.com/prysmaticlabs/prysm/v4/config/features"
|
2020-05-30 23:44:34 -07:00
|
|
|
"github.com/urfave/cli/v2"
|
2019-09-11 14:38:35 -04: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...)
|
|
|
|
}
|
2021-09-14 18:18:39 -07:00
|
|
|
helpFlags = features.ActiveFlags(helpFlags)
|
|
|
|
appFlags = features.ActiveFlags(appFlags)
|
2019-09-11 14:38:35 -04:00
|
|
|
|
|
|
|
for _, flag := range appFlags {
|
|
|
|
if !doesFlagExist(flag, helpFlags) {
|
2020-03-19 14:46:44 -07:00
|
|
|
t.Errorf("Flag %s does not exist in help/usage flags.", flag.Names()[0])
|
2019-09-11 14:38:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, flag := range helpFlags {
|
|
|
|
if !doesFlagExist(flag, appFlags) {
|
|
|
|
t.Errorf("Flag %s does not exist in main.go, "+
|
2020-03-19 14:46:44 -07:00
|
|
|
"but exists in help flags", flag.Names()[0])
|
2019-09-11 14:38:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func doesFlagExist(flag cli.Flag, flags []cli.Flag) bool {
|
|
|
|
for _, f := range flags {
|
2020-03-19 14:46:44 -07:00
|
|
|
if f.String() == flag.String() {
|
2019-09-11 14:38:35 -04:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|