Skip to content

Add Ninja snapshot test for command_available expansion (#310)#360

Draft
leynos wants to merge 1 commit into
mainfrom
issue-310-command-available-snapshot
Draft

Add Ninja snapshot test for command_available expansion (#310)#360
leynos wants to merge 1 commit into
mainfrom
issue-310-command-available-snapshot

Conversation

@leynos

@leynos leynos commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #310

Adds the snapshot test proposed in the issue: command_available_manifest_ninja_snapshot in tests/ninja_snapshot_tests.rs, following the structure of conditional_manifest_ninja_snapshot.

  • Inline manifest with two complementary actions guarded by when: command_available("netsuke-command-that-should-not-exist", cwd_mode="never") and its negation, plus a simple targets section.
  • Pipeline: manifest::from_strBuildGraph::from_manifestninja_gen::generate.
  • ensure! assertions confirm the fallback action is present and the preferred action absent.
  • Snapshot bound to tests/snapshots/ninja as command_available_manifest_ninja; the committed .snap shows the fallback rule/build edge and the unconditional target, with no preferred content.

Deterministic with no real binary on PATH (absent command name + cwd_mode="never").

Validation

  • cargo test --test ninja_snapshot_tests — 4 passed
  • make check-fmt / make lint / make test — pass (37 suites)

🤖 Generated with Claude Code

Summary by Sourcery

Tests:

  • Add command_available Ninja snapshot test covering preferred vs fallback actions when the referenced command is not available on PATH.

PR #309 introduced the `command_available` stdlib predicate but no
snapshot pinned the generated Ninja output for the path where a
`when: command_available(...)` / `when: not command_available(...)`
pair filters top-level actions before `ninja_gen::generate`.

Add `command_available_manifest_ninja_snapshot`, modelled on
`conditional_manifest_ninja_snapshot`: the manifest guards two
complementary actions on a command name guaranteed absent (with
`cwd_mode="never"` for determinism), asserts the fallback action is
present and the preferred action absent, and snapshots the Ninja
output to `tests/snapshots/ninja`.
@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: c53da8d5-e17d-4cf6-be61-31e7bee8ce8e

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-310-command-available-snapshot

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 a new deterministic Ninja snapshot test to validate command_available-based conditional action expansion, including assertions on preferred vs fallback actions and a committed snapshot file.

File-Level Changes

Change Details Files
Add a new Ninja snapshot test that exercises command_available-based conditional actions and binds them to a snapshot file.
  • Define an inline manifest YAML with preferred and fallback actions guarded by command_available and its negation using cwd_mode="never" to ensure determinism.
  • Generate a BuildGraph from the manifest and run ninja_gen::generate to produce Ninja output for testing.
  • Add ensure! assertions that confirm the fallback action appears and the preferred action does not appear in the generated Ninja file.
  • Configure insta snapshot Settings to use the tests/snapshots/ninja directory and bind the test output under the command_available_manifest_ninja snapshot name.
  • Introduce a new committed .snap file containing the expected Ninja output for this scenario.
tests/ninja_snapshot_tests.rs
tests/snapshots/ninja/ninja_snapshot_tests__command_available_manifest_ninja.snap

Assessment against linked issues

Issue Objective Addressed Explanation
#310 Add a new snapshot test command_available_manifest_ninja_snapshot in tests/ninja_snapshot_tests.rs that builds an inline manifest exercising when: command_available(...) / when: not command_available(...), runs manifest::from_strBuildGraph::from_manifestninja_gen::generate, asserts fallback-present/preferred-absent, and snapshots the Ninja output via insta with snapshot_path set to tests/snapshots/ninja and snapshot name command_available_manifest_ninja.
#310 Ensure the test is deterministic by using cwd_mode="never" and a guaranteed-absent command name so no real binaries on PATH affect the result.
#310 Commit the corresponding insta snapshot file at tests/snapshots/ninja/command_available_manifest_ninja.snap for the new test.

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.

Add snapshot test for command_available manifest expansion in ninja_snapshot_tests.rs

1 participant