Skip to content

fix(cli): gate test-only selector and model helpers behind cfg(test) - #2573

Open
1688mengdie wants to merge 1 commit into
GCWing:mainfrom
BitFun-SIG:fix/ci-warning-testonly-cfg
Open

fix(cli): gate test-only selector and model helpers behind cfg(test)#2573
1688mengdie wants to merge 1 commit into
GCWing:mainfrom
BitFun-SIG:fix/ci-warning-testonly-cfg

Conversation

@1688mengdie

Copy link
Copy Markdown

Summary

Fixes #2567

Gate three CLI helpers that are referenced exclusively from #[cfg(test)] modules behind #[cfg(test)] (one attribute line each):

  • resolve_session_model_display_id in src/apps/cli/src/model_selection.rs
  • AgentSelectorState::show_modes_only in src/apps/cli/src/ui/agent_selector.rs
  • ChatView::show_agent_modes_only in src/apps/cli/src/ui/chat/popups.rs

Production builds no longer carry the three dead symbols or emit their dead-code warnings; the unit tests keep using the helpers unchanged (see issue #2567 for the run evidence with file:line and rule names).

Type and Areas

Type: bug fix (build warnings cleanup)

Areas: Rust CLI

Motivation / Impact

No direct user-facing change. Non-test builds stop emitting 3 dead-code warnings on every full CI run of main, and the production binary stops carrying test-only symbols.

Verification

  • cargo check --locked -p bitfun-cli on Windows: exit 0, the three dead_code warnings gone (crate baseline 19 warnings down to 16 on Windows; the remaining ones are other symbols covered by separate PRs).
  • Focused tests still pass with the gates in place: cargo test --locked -p bitfun-cli --bin bitfun model_selection (6 passed), ... agent_selector (12 passed), ... pending_mode_update — the show_agent_modes_only consumer test (1 passed), 0 failed overall.
  • Full cross-platform test surface depends on the CI ubuntu/macos runners: the CLI Tests jobs should confirm the gated helpers still compile for the test profile on all platforms (n/a locally — no Linux/macOS machine available; the platform matrix in CI is exactly the place this gets verified).

Reviewer Notes

  • Three files, +1 attribute line each, zero deletions, zero behavior change.
  • No #[allow] suppression is introduced.
  • AI-assisted change, lightly tested (cargo check + targeted unit tests on Windows; cross-platform behavior verified by CI).

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable. (n/a — no user-facing change)

Three CLI helpers are referenced exclusively from #[cfg(test)] modules, so
release builds report them as dead code in the upstream CI logs:
- resolve_session_model_display_id in model_selection.rs (called only by
  the tests in the same file)
- AgentSelectorState::show_modes_only in ui/agent_selector.rs (called only
  by tests in the same file and via ChatView::show_agent_modes_only)
- ChatView::show_agent_modes_only in ui/chat/popups.rs (called only by the
  popup test in the same file)

Gate each helper with #[cfg(test)] so the production binary no longer
carries dead symbols while the unit tests keep using them.

Adopted-from: taiji 8082098 (cfg(test) gate hunks).

Test: cargo check --locked -p bitfun-cli exit 0 with no dead_code warnings
for the three symbols; cargo test -p bitfun-cli --bin bitfun
model_selection exit 0 (6 passed); cargo test -p bitfun-cli --bin bitfun
agent_selector exit 0 (12 passed); cargo test -p bitfun-cli --bin bitfun
pending_mode_update (the show_agent_modes_only consumer) exit 0 (1 passed).
AI: implemented with AI assistance, lightly tested (cargo check + targeted
unit tests).
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.

[Bug]: dead_code warnings for three CLI helpers referenced only from test code

1 participant