Skip to content

[IMPROVEMENT] Fail the tests when a command line option has no test - #2410

Open
Deepak-negi11 wants to merge 2 commits into
CCExtractor:masterfrom
Deepak-negi11:test/cli-option-coverage
Open

Deepak-negi11 wants to merge 2 commits into
CCExtractor:masterfrom
Deepak-negi11:test/cli-option-coverage

Conversation

@Deepak-negi11

@Deepak-negi11 Deepak-negi11 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

In raising this pull request, I confirm the following (please check boxes):

Reason for this PR:

  • This PR adds new functionality.
  • This PR fixes a bug that I have personally experienced or that a real user has reported and for which a sample exists.
  • This PR is porting code from C to Rust.

Sanity check:

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • If the PR adds new functionality, I've added it to the changelog. If it's just a bug fix, I have NOT added it to the changelog.
  • I am NOT adding new C code unless it's to fix an existing, reproducible bug.

Repro instructions:

cd src/rust && cargo test --lib test_every_option_has_a_test

Change Result
Add a new option to args.rs with no test Fails: "These options have no test, please add one: [brand-new-option]"
Add a test for --srt (still in the list) Fails: "These options have a test now, remove them from UNTESTED_OPTIONS: [srt]"
Remove mcc from the list without adding a test Fails: "These options have no test, please add one: [mcc]"

Part of #2408 (step 2). Depends on #2409; this branch includes its commit.

Problem

Nothing stops an option from being added or changed without a test. 24 options have no test at all today, including --stdin, --udp, --tcp, --stream, --srt, --sami and --smi. (-smi is in fact broken right now.)

What this adds

  • test_every_option_has_a_test: gets every option from clap and checks that a test passes it on the command line, as --name or -name. Only the test modules of parser.rs and lib.rs, plus cli_tests.rs, are searched, so option names in normal code don't count.
  • UNTESTED_OPTIONS: the 24 options without a test today. The test also fails if a listed option gets a test, so the list can only shrink. The next PRs add the missing tests and empty it.
  • The test also fails if a listed entry is not a real option (a typo, or an option that was removed). It checks that some test passes the option; checking the C value is what [IMPROVEMENT] Test command line options through ccxr_parse_parameters into C #2409's helper is for.

Testing

  • cargo test (439 passed), cargo fmt --check, cargo clippy -- -D warnings.
  • Checked the three failure cases in the table above.

Copilot AI balanced review requested due to automatic review settings October 20, 2026 19:22

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

2 participants