Skip to content

test: consolidate 4 duplicate top-level-help tests into one stronger check#1538

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
test-reducer/consolidate-toplevel-help-tests-245fd82d296157b1
Draft

test: consolidate 4 duplicate top-level-help tests into one stronger check#1538
github-actions[bot] wants to merge 1 commit into
mainfrom
test-reducer/consolidate-toplevel-help-tests-245fd82d296157b1

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Test Suite Reduction: top-level help integration tests

What was wrong

Four structurally identical *_is_in_top_level_help tests were spread across list_integration.rs, disable_integration.rs, remove_integration.rs, and status_integration.rs. Each one:

  • Spawned ado-aw --help as a separate process
  • Checked for a single word with stdout.contains("<word>") over the entire help output
  • Used no scoping to the Commands section — so the word "list" or "status" could match description prose and produce a false-pass even if the subcommand were hidden or removed

The configure_is_hidden_in_top_level_help test in secrets_integration.rs already shows the correct approach: parse the Commands section and scope the assertion there.

Changes

File Test Action Reason
tests/list_integration.rs list_is_in_top_level_help Removed Duplicate process spawn; stdout.contains("list") is too broad ("list" is a common word)
tests/disable_integration.rs disable_is_listed_in_top_level_help Removed Duplicate process spawn; naïve single-word check
tests/remove_integration.rs remove_is_listed_in_top_level_help Removed Duplicate process spawn; naïve single-word check
tests/status_integration.rs status_is_in_top_level_help Removed Duplicate process spawn; naïve single-word check
tests/cli_tests.rs test_lifecycle_subcommands_appear_in_top_level_help_commands_section Added Single process spawn; scopes check to the Commands section; anchors each match with " <cmd>" (two leading spaces matching clap's indentation) to prevent prose false-positives

Verification

  • cargo check: ✅
  • cargo test --test cli_tests --test list_integration --test disable_integration --test remove_integration --test status_integration: all tests pass ✅

Generated by Test Reducer · 107 AIC · ⌖ 12.3 AIC · ⊞ 8.7K ·

…check

The four `*_is_in_top_level_help` tests spread across list, disable,
remove, and status integration test files were structurally identical:
each spawned `ado-aw --help` separately and checked for a single
word via `stdout.contains()` over the entire output.

Problems:
- Common words like "list" and "status" could match description prose,
  producing false-passes if the subcommand were hidden or removed.
- Four independent process spawns for the same binary invocation.
- The weaker assertion style contrasts with `configure_is_hidden_in_`
  `top_level_help` in secrets_integration.rs, which correctly scopes
  its check to the Commands section.

Replace all four with a single `test_lifecycle_subcommands_appear_in_`
`top_level_help_commands_section` test in cli_tests.rs that:
- Spawns the binary exactly once.
- Parses the Commands section (between "Commands:" and "Options:").
- Asserts each subcommand appears as an indented command entry
  (`"  <cmd>"`), preventing prose false-positives.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

0 participants