Skip to content

fix(go): preserve -C as the first test flag - #3520

Open
LimJiAn wants to merge 2 commits into
rtk-ai:developfrom
LimJiAn:fix/go-test-c-flag-order
Open

LimJiAn wants to merge 2 commits into
rtk-ai:developfrom
LimJiAn:fix/go-test-c-flag-order

Conversation

@LimJiAn

@LimJiAn LimJiAn commented Aug 10, 2026 •

Copy link
Copy Markdown

Fixes #4362

Summary

  • Keep the Go chdir flag first when RTK injects -json into go test.
  • Support all forms accepted by Go: -C DIR, -C=DIR, --C DIR, and --C=DIR.
  • Cover all four forms in the existing regression test.

Why

Go processes the chdir flag before normal command parsing and requires it to be the first flag. RTK previously prepended -json, producing an invalid command such as:

go test -json -C DIR ./...

The Go implementation explicitly accepts both one- and two-dash forms:
https://go.dev/src/cmd/go/main.go

Validation

  • cargo fmt --all --check
  • cargo clippy --all-targets — 0 warnings
  • cargo test --all — 2656 passed, 8 ignored
  • E2E: rtk -v go test -C DIR fmt
  • E2E: rtk -v go test -C=DIR fmt
  • E2E: rtk -v go test --C DIR fmt
  • E2E: rtk -v go test --C=DIR fmt

All E2E cases placed -json after the chdir argument and passed 80 tests.

@CLAassistant

CLAassistant commented Aug 10, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@LimJiAn
LimJiAn marked this pull request as ready for review August 10, 2026 10:10
@LimJiAn

LimJiAn commented Sep 30, 2026

Copy link
Copy Markdown
Author

Rebased on latest develop, still applies cleanly. Linked #4362 with a repro. Could a maintainer approve the CI run?

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.

rtk go test -C DIR fails: -json is injected before -C

2 participants