2019-10-31 03:26:55 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-04-22 15:53:09 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/shared/featureconfig"
|
2020-08-18 12:41:25 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
2020-05-31 06:44:34 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
2019-10-31 03:26:55 +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...)
|
|
|
|
}
|
2020-04-22 15:53:09 +00:00
|
|
|
helpFlags = featureconfig.ActiveFlags(helpFlags)
|
|
|
|
appFlags = featureconfig.ActiveFlags(appFlags)
|
2019-10-31 03:26:55 +00:00
|
|
|
|
|
|
|
for _, flag := range appFlags {
|
2020-08-18 12:41:25 +00:00
|
|
|
assert.Equal(t, true, doesFlagExist(flag, helpFlags), "Flag %s does not exist in help/usage flags.", flag.Names()[0])
|
2019-10-31 03:26:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, flag := range helpFlags {
|
2020-08-18 12:41:25 +00:00
|
|
|
assert.Equal(t, true, doesFlagExist(flag, appFlags), "Flag %s does not exist in main.go, but exists in help flags", flag.Names()[0])
|
2019-10-31 03:26:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func doesFlagExist(flag cli.Flag, flags []cli.Flag) bool {
|
|
|
|
for _, f := range flags {
|
2020-04-22 15:53:09 +00:00
|
|
|
if f.String() == flag.String() {
|
2019-10-31 03:26:55 +00:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|