Skip to content

Add snapshot test for command_available manifest expansion in ninja_snapshot_tests.rs #310

@coderabbitai

Description

@coderabbitai

Summary

Add a snapshot test to tests/ninja_snapshot_tests.rs that captures the generated Ninja output for a manifest that uses command_available branching in its when clauses, validated with insta::assert_snapshot! alongside the existing conditional_manifest_ninja_snapshot test.

Background

PR #309 introduced the command_available stdlib predicate and exercised it through BDD and unit tests, but no Ninja-output snapshot test exists for the code path where a when: command_available(...) / when: not command_available(...) pair filters top-level actions during manifest expansion and the result is handed to ninja_gen::generate.

Proposed work

Add a new #[test] function — suggested name: command_available_manifest_ninja_snapshot — in tests/ninja_snapshot_tests.rs, following the same structure as conditional_manifest_ninja_snapshot:

  1. Define an inline manifest YAML that declares two complementary actions:
    • one guarded by when: command_available("netsuke-command-that-should-not-exist", cwd_mode="never")
    • one guarded by when: not command_available("netsuke-command-that-should-not-exist", cwd_mode="never")
    • plus a simple targets section so the Ninja file is non-trivial
  2. Call manifest::from_strBuildGraph::from_manifestninja_gen::generate.
  3. Use ensure! assertions to confirm the fallback action is present and the preferred action is absent from ninja_content.
  4. Bind insta::Settings with snapshot_path pointing at tests/snapshots/ninja (matching the convention used by the existing snapshot tests) and call assert_snapshot!("command_available_manifest_ninja", ninja_content).

The test must be deterministic without any real binary on PATH (hence cwd_mode="never" and a command name that is guaranteed absent).

Acceptance criteria

  • New test compiles and passes with cargo test --test ninja_snapshot_tests.
  • A committed insta snapshot file appears at tests/snapshots/ninja/command_available_manifest_ninja.snap.
  • The snapshot file is reviewed and approved before merging.

References

  • PR Expand top-level action flow control (3.14.2) #309 — introduces command_available
  • tests/ninja_snapshot_tests.rsconditional_manifest_ninja_snapshot as the model
  • tests/data/actions_command_available_absent.yml — existing fixture for the absent-command path

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions