You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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
Use ensure! assertions to confirm the fallback action is present and the preferred action is absent from ninja_content.
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.
Summary
Add a snapshot test to
tests/ninja_snapshot_tests.rsthat captures the generated Ninja output for a manifest that usescommand_availablebranching in itswhenclauses, validated withinsta::assert_snapshot!alongside the existingconditional_manifest_ninja_snapshottest.Background
PR #309 introduced the
command_availablestdlib predicate and exercised it through BDD and unit tests, but no Ninja-output snapshot test exists for the code path where awhen: command_available(...)/when: not command_available(...)pair filters top-level actions during manifest expansion and the result is handed toninja_gen::generate.Proposed work
Add a new
#[test]function — suggested name:command_available_manifest_ninja_snapshot— intests/ninja_snapshot_tests.rs, following the same structure asconditional_manifest_ninja_snapshot:when: command_available("netsuke-command-that-should-not-exist", cwd_mode="never")when: not command_available("netsuke-command-that-should-not-exist", cwd_mode="never")targetssection so the Ninja file is non-trivialmanifest::from_str→BuildGraph::from_manifest→ninja_gen::generate.ensure!assertions to confirm the fallback action is present and the preferred action is absent fromninja_content.insta::Settingswithsnapshot_pathpointing attests/snapshots/ninja(matching the convention used by the existing snapshot tests) and callassert_snapshot!("command_available_manifest_ninja", ninja_content).The test must be deterministic without any real binary on
PATH(hencecwd_mode="never"and a command name that is guaranteed absent).Acceptance criteria
cargo test --test ninja_snapshot_tests.instasnapshot file appears attests/snapshots/ninja/command_available_manifest_ninja.snap.References
command_availabletests/ninja_snapshot_tests.rs—conditional_manifest_ninja_snapshotas the modeltests/data/actions_command_available_absent.yml— existing fixture for the absent-command path