diff options
| author | Tomas Aschan <[email protected]> | 2025-09-01 09:03:48 +0200 |
|---|---|---|
| committer | Tomas Aschan <[email protected]> | 2025-09-01 09:03:48 +0200 |
| commit | 7412009ab0f29ad89cbc6625911a58c0618cf31e (patch) | |
| tree | 23b5f8a728b5e6c398f066535567a3583dd70d80 /flag_test.go | |
| parent | b9c16fa5ec31cd7339621b8d208bf4f2769486c4 (diff) | |
fix: Restore ParseErrorsWhitelist name for now
This will be removed in a future release, but is reintroduced here to not break backwards compatibility.
Diffstat (limited to 'flag_test.go')
| -rw-r--r-- | flag_test.go | 11 |
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) { |
