Skip to content

Preserve separate values in ParseSkippedFlags - #535

Draft
liuyinchu wants to merge 2 commits into
spf13:masterfrom
liuyinchu:patch-1
Draft

liuyinchu wants to merge 2 commits into
spf13:masterfrom
liuyinchu:patch-1

Conversation

@liuyinchu

Copy link
Copy Markdown

ParseSkippedFlags currently keeps only arguments starting with -test.. A valid pair such as -test.run TestExample therefore loses its value; with mixed flags it can consume a later test flag as that value instead.

Keep the following argument for a registered non-boolean test flag. Equals-form values and boolean flags remain unchanged, including custom values implementing IsBoolFlag(). Let Go's parser continue reporting unknown flags and missing/invalid values. No changes to pflag's main parser or delimiter behavior.

The regression fails on unchanged production code for ten table cases and a custom non-boolean flag. Full race suites pass on Go 1.27.3 and 1.26.10; vet and configured golangci-lint 2.13.2 on Go 1.26.10 pass. An additional 34-case comparison agrees with Go's parser. The 386 test binary compiles but cannot execute in this environment; the remaining upstream version matrix has not run.

This fixes value handling in the helper introduced by #424, rather than replacing its original #423 behavior.

AI-assisted investigation, implementation, tests and writing; independently reviewed. No production incident is claimed.

@CLAassistant

CLAassistant commented Oct 30, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Ekko82 Ekko82 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran the three new ParseSkippedFlags test functions on Windows/386 with Go 1.27.1 (GOOS=windows, GOARCH=386, CGO_ENABLED=0), supplementing the compile-only 386 result in the description:

go test -json -count=1 -run '^TestParseSkippedFlags(SeparateValues|MissingOrUnknownFlag|CustomBoolFlag)$' .

All 15 leaf cases passed at 5b8b51e675bb1a685b8b3a529b5ed3516413f24e with the PR sources unchanged. I did not run the full suite, race tests or other Go versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants