Skip to content

Add property tests for CLI merge invariants (#317)#368

Draft
leynos wants to merge 1 commit into
mainfrom
issue-317-merge-precedence-proptests
Draft

Add property tests for CLI merge invariants (#317)#368
leynos wants to merge 1 commit into
mainfrom
issue-317-merge-precedence-proptests

Conversation

@leynos

@leynos leynos commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #317

Adds proptest coverage for the merge invariants introduced by PR #273, at the CliConfig::merge_from_layers boundary (no filesystem or environment mutation, so the cases run fast and in parallel):

  • Merge precedence: for any combination of present/absent layers, the highest-precedence layer supplying jobs wins (CLI > env > file > defaults).
  • List appending: append-merged lists concatenate in layer order (file → env → CLI) for arbitrary generated lists; file-supplied cmds.build.targets survive the merge intact.
  • Validation rules: across the full theme × no_emoji and spinner_mode × progress domains, validation fires for exactly the documented conflicting pairs; jobs is accepted exactly within 1..=64.

Validation

  • make check-fmt / make lint / make test — pass (37 suites; 5 new property tests green)

🤖 Generated with Claude Code

Summary by Sourcery

Add property-based tests to verify CLI configuration merge invariants at the CliConfig::merge_from_layers boundary.

Tests:

  • Add proptest-based coverage for layer precedence of the jobs setting across file, environment, and CLI inputs.
  • Add generative tests ensuring list-merged CLI options append in file → environment → CLI order while preserving file-specified build targets.
  • Add property tests validating documented conflict rules for theme/no_emoji and spinner_mode/progress combinations.
  • Add property tests enforcing the accepted jobs range matches documented bounds.

The layered configuration merge's invariants — precedence ordering,
list-appending, and cross-field validation — were exercised only by
hand-picked examples. Add generative coverage at the
`CliConfig::merge_from_layers` boundary:

- `jobs_follow_layer_precedence`: for any combination of present and
  absent layers, the highest-precedence layer supplying `jobs` wins
  (CLI over environment over file);
- `append_lists_concatenate_in_layer_order`: append-merged lists
  concatenate file, environment, then CLI values for arbitrary lists,
  and file-supplied build targets survive intact;
- `theme_no_emoji_validation_matches_documented_rules` and
  `spinner_progress_validation_matches_documented_rules`: across the
  full enum domains, validation fires for exactly the documented
  conflicting pairs;
- `jobs_bounds_validation_matches_documented_rules`: `jobs` is
  accepted exactly within `1..=64`.

`proptest` was already a dev-dependency.
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 50419933-5622-4551-8128-6fe6f3eeb281

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-317-merge-precedence-proptests

Comment @coderabbitai help to get the list of available commands and usage tips.

@sourcery-ai

sourcery-ai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds proptest-based property tests for CLI configuration merge invariants at the CliConfig::merge_from_layers boundary, covering layer precedence, list appending behavior, and validation rule correctness for multiple configuration fields.

File-Level Changes

Change Details Files
Introduce property-based tests to verify layer precedence for the jobs configuration across file, environment, and CLI sources.
  • Add helper merge_jobs_layers to construct MergeComposer layers (defaults, file, env, CLI) and call CliConfig::merge_from_layers for optional jobs values
  • Define jobs_value strategy constrained to the valid jobs range 1..=MAX_JOBS
  • Add proptest that generates optional jobs values per layer and asserts merged.jobs equals the highest-precedence non-None value (CLI over env over file)
tests/cli_tests/merge_property.rs
Add property tests for list-append merge semantics for fetch_allow_scheme and cmds.build.targets.
  • Add merge_lists helper that builds a MergeComposer with defaults plus file/env/CLI layers for fetch_allow_scheme and file-only cmds.build.targets
  • Define scheme_list strategy for random short lowercase scheme names
  • Add proptest that asserts merged.fetch_allow_scheme equals concatenation of file, env, and CLI lists in that order, and that cmds.build.targets equals the file-provided list exactly
tests/cli_tests/merge_property.rs
Add property tests that configuration validation rejects exactly the documented conflicting combinations for theme/no_emoji and spinner_mode/progress, and enforces jobs bounds.
  • Add merge_file_layer helper that merges a single file-like JSON layer on top of defaults through CliConfig::merge_from_layers
  • Define generators for optional theme, spinner_mode, and tristate booleans, modeling full configuration domains
  • Add proptest asserting theme/no_emoji combinations fail only for (unicode,true) and (ascii,false)
  • Add proptest asserting spinner_mode/progress combinations fail only for (disabled,true) and (enabled,false)
  • Add proptest asserting jobs values are accepted only in 1..=MAX_JOBS and rejected otherwise
tests/cli_tests/merge_property.rs
Wire the new property test module into the CLI test suite.
  • Register merge_property test module from tests/cli_tests/mod.rs so it runs with the rest of the CLI tests
tests/cli_tests/mod.rs

Assessment against linked issues

Issue Objective Addressed Explanation
#317 Introduce property-based tests (using proptest) that generate arbitrary CLI configuration layer values to exercise the CLI merge pipeline invariants.
#317 Verify via property-based tests that merge ordering and list-appending semantics are respected (defaults → file → environment → CLI; list fields like cmds.build.targets and fetch_allow_scheme append in correct layer order and preserve file-supplied targets).
#317 Verify via property-based tests that CLI configuration validation rules fire correctly across the full domain of relevant options (theme/no_emoji, spinner_mode/progress, and jobs bounds).

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

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.

Property-based tests for CLI merge precedence and validation invariants using proptest

1 participant