Skip to content

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

Merged
leynos merged 2 commits into
mainfrom
issue-310-command-available-snapshot
Aug 16, 2026
Merged

Add Ninja snapshot test for command_available expansion (#310)#360
leynos merged 2 commits 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.

References

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: cb7527c9-62d7-4521-a689-c4962fbb992c

📥 Commits

Reviewing files that changed from the base of the PR and between 6b6e9e6 and 3315340.

⛔ Files ignored due to path filters (1)
  • tests/snapshots/ninja/ninja_snapshot_tests__command_available_manifest_ninja.snap is excluded by !**/*.snap
📒 Files selected for processing (4)
  • docs/developers-guide.md
  • src/manifest/mod.rs
  • src/manifest/parse_with_config.rs
  • tests/ninja_snapshot_tests.rs
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • leynos/monotony (auto-detected)
  • leynos/rstest-bdd (auto-detected)
  • leynos/ortho-config (auto-detected)
  • leynos/whitaker (auto-detected)
  • leynos/shared-actions (auto-detected)

Included review availability: 3 reviews are currently available. Based on recent review activity, included reviews refill at 4 per hour.


Summary

  • Add command_available_manifest_ninja_snapshot for complementary command_available(...) conditions.
  • Force an empty PATH to make command resolution deterministic.
  • Add manifest::from_str_with_env_and_config for injected environment and configuration.
  • Generate Ninja output through manifest parsing and build graph expansion.
  • Verify that the fallback action is present and the preferred action is absent.
  • Record the output in tests/snapshots/ninja/command_available_manifest_ninja.snap.
  • Document the injected-environment parsing seam.
  • Pass Ninja snapshot tests, formatting, linting, and the full test suite.

Walkthrough

Add configurable manifest parsing with injected environment and standard-library configuration. Add an end-to-end Ninja snapshot test for command_available using an empty search path and cwd_mode="never". Verify that only the fallback action is emitted.

Changes

Manifest configuration and Ninja coverage

Layer / File(s) Summary
Expose configurable manifest parsing
src/manifest/parse_with_config.rs, src/manifest/mod.rs, docs/developers-guide.md
Add and re-export manifest::from_str_with_env_and_config. Document the injected-environment API example.
Validate command-based Ninja output
tests/ninja_snapshot_tests.rs
Configure deterministic command resolution. Parse actions guarded by command_available, verify the fallback action, and snapshot the generated Ninja output.

Possibly related PRs

  • leynos/netsuke#410: Adds related StdlibConfig and manifest environment handling.
  • leynos/netsuke#515: Introduces related command-path override and injected manifest environment APIs.
  • leynos/netsuke#558: Implements related hermetic environment injection and configuration discovery.

Poem

An empty path makes the choice,
The fallback action speaks with force.
Ninja captures the result,
A snapshot keeps the branch explicit.
cwd_mode="never" keeps it fixed.

Merge Risk: ⚪ Minimal · up to 33153

This PR adds a localized deterministic Ninja snapshot test and related documentation; no actionable merge-blocking risk remains after normal checks and review.


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (8 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ❓ Inconclusive The code meets the issue objectives, but the committed snapshot cannot be verified because the relevant .snap file was excluded. Verify tests/snapshots/ninja/ninja_snapshot_tests__command_available_manifest_ninja.snap; it was excluded by the !**/*.snap path filter.
Testing (Overall) ❓ Inconclusive Placeholder not final. Continue investigation.
User-Facing Documentation ❓ Inconclusive Investigation is still in progress; no verdict submitted yet. Inspect the changed public API and the existing user guide before deciding.
Developer Documentation ❓ Inconclusive Diff evidence is not yet available; the working tree is clean despite the stated changes. Provide the pull request base revision or a usable diff, then verify the developer-guide coverage for the new API.
Testing (Compile-Time / Ui) ❓ Inconclusive Investigation has not started. Inspect the pull-request diff and snapshot assertions before deciding whether the testing requirements are met.
Observability ❓ Inconclusive Investigation in progress. Inspect the committed diff and parser call paths before deciding whether the change adds an operational failure mode.
Performance And Resource Use ❓ Inconclusive Investigation is not complete; no verdict yet. Await repository evidence.
Architectural Complexity And Maintainability ❓ Inconclusive placeholder placeholder
✅ Passed checks (12 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the Ninja snapshot test and references the directly linked issue, #310.
Description check ✅ Passed The description explains the snapshot test, deterministic PATH configuration, validation results, and linked issue.
Out of Scope Changes check ✅ Passed The test, PATH configuration seam, public API export, and developer documentation directly support the linked issue objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Module-Level Documentation ✅ Passed Accept: the new parse_with_config module has //! documentation covering purpose, use, and its relationship to the parent parser; existing changed modules are also documented.
Testing (Unit And Behavioural) ✅ Passed The added test exercises manifest parsing, BuildGraph expansion, and Ninja generation, then checks both branches and a committed snapshot at the required behavioural boundary.
Testing (Property / Proof) ✅ Passed The change adds a deterministic example-based snapshot and a parser configuration seam; it does not introduce a stated invariant over a range of inputs, states, orderings, or transitions.
Unit Architecture ✅ Passed The PR adds an explicit StdlibConfig and EnvReader boundary; parsing returns Result and uses existing fallible query paths without introducing writes, mutation, or hidden clients.
Domain Architecture ✅ Passed Placeholder
Security And Privacy ✅ Passed Keep the change: the PR adds deterministic test data and an explicit PATH override; the complete diff contains no credentials, secrets, sensitive data, or new secret-bearing logs.
Concurrency And State ✅ Passed HEAD^..HEAD adds a synchronous parser wrapper and test; no async, task, lock, or shared-state code was added, and the existing resolver cache Mutex is unchanged.
Rust Compiler Lint Integrity ✅ Passed Keep the change: the diff adds no broad lint suppressions, artificial anchors, or new clone calls; every new import and public re-export has a real use, and the owned config matches register_with_c...
📋 Issue Planner

Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).

View plan for ticket: #310

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 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.

@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

@lodyai
lodyai Bot force-pushed the issue-310-command-available-snapshot branch from 5aebb0b to 6eff68e Compare August 9, 2026 17:31
codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

@leynos
leynos marked this pull request as ready for review August 10, 2026 00:14

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @leynos, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai coderabbitai Bot added the Issue label Aug 10, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6eff68ec38

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/ninja_snapshot_tests.rs Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/ninja_snapshot_tests.rs`:
- Around line 135-145: Update the manifest expansion setup in the ninja snapshot
test to make the unavailable-command fixture independent of the host PATH.
Configure the relevant StdlibConfig using with_path_override with a controlled
path, or use an absent temporary direct path, while preserving the existing
command_available conditions and avoiding process-environment mutation.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f6c7d451-1265-4c3f-bc8b-1d84a829ddbf

📥 Commits

Reviewing files that changed from the base of the PR and between 487f77e and 6eff68e.

⛔ Files ignored due to path filters (1)
  • tests/snapshots/ninja/ninja_snapshot_tests__command_available_manifest_ninja.snap is excluded by !**/*.snap
📒 Files selected for processing (1)
  • tests/ninja_snapshot_tests.rs
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • leynos/rstest-bdd (auto-detected)
  • leynos/ortho-config (auto-detected)
  • leynos/whitaker (auto-detected)
  • leynos/shared-actions (auto-detected)

Comment thread tests/ninja_snapshot_tests.rs Outdated
@leynos
leynos force-pushed the issue-310-command-available-snapshot branch from 6eff68e to 7a5b507 Compare August 14, 2026 12:39
codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

leynos and others added 2 commits August 15, 2026 22:34
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`.
The fixture relied on a command name guaranteed absent, but
`command_available` still searches every directory on the host PATH even
with `cwd_mode="never"`; a developer or CI image carrying a binary named
`netsuke-command-that-should-not-exist` would select the preferred action
and break both the assertions and the snapshot.

Add a public `manifest::from_str_with_env_and_config` entrypoint so a test
can inject a full `StdlibConfig` alongside the existing `EnvReader` seam,
then pin the resolver to an empty PATH with
`StdlibConfig::from_current_dir()?.with_path_override("")`. With
`cwd_mode="never"` the workspace fallback is disabled too, so the
expansion is deterministic on every host without touching the process
environment. The new entrypoint lives in `src/manifest/parse_with_config.rs`
to keep `src/manifest/mod.rs` inside the 400-line Whitaker limit.

Document the seam in the developers-guide injected-environment list.

Co-Authored-By: Claude <noreply@anthropic.com>
@leynos
leynos force-pushed the issue-310-command-available-snapshot branch from 8ea268a to 3315340 Compare August 15, 2026 20:47
codescene-access[bot]

This comment was marked as outdated.

@codescene-access codescene-access Bot 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.

No quality gates enabled for this code.

@pandalump

Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot removed the Issue label Aug 16, 2026
@leynos
leynos merged commit 134a9d7 into main Aug 16, 2026
17 checks passed
@leynos
leynos deleted the issue-310-command-available-snapshot branch August 16, 2026 11:00
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

2 participants