aboutsummaryrefslogtreecommitdiff
path: root/flag_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'flag_test.go')
-rw-r--r--flag_test.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/flag_test.go b/flag_test.go
index 31491c8..f8ee431 100644
--- a/flag_test.go
+++ b/flag_test.go
@@ -447,11 +447,11 @@ func testParseAll(f *FlagSet, t *testing.T) {
}
}
-func testParseWithUnknownFlags(f *FlagSet, t *testing.T) {
+func testParseWithUnknownFlags(f *FlagSet, t *testing.T, setUnknownFlags func(f *FlagSet)) {
if f.Parsed() {
t.Error("f.Parse() = true before Parse")
}
- f.ParseErrorsAllowlist.UnknownFlags = true
+ setUnknownFlags(f)
f.BoolP("boola", "a", false, "bool value")
f.BoolP("boolb", "b", false, "bool2 value")
@@ -649,7 +649,12 @@ func TestParseAll(t *testing.T) {
func TestIgnoreUnknownFlags(t *testing.T) {
ResetForTesting(func() { t.Error("bad parse") })
- testParseWithUnknownFlags(GetCommandLine(), t)
+ testParseWithUnknownFlags(GetCommandLine(), t, func(f *FlagSet) { f.ParseErrorsAllowlist.UnknownFlags = true })
+}
+
+func TestIgnoreUnknownFlagsBackwardsCompat(t *testing.T) {
+ ResetForTesting(func() { t.Error("bad parse") })
+ testParseWithUnknownFlags(GetCommandLine(), t, func(f *FlagSet) { f.ParseErrorsWhitelist.UnknownFlags = true })
}
func TestFlagSetParse(t *testing.T) {