Add property tests for cycles, separators, interpolation (#322)#377
Add property tests for cycles, separators, interpolation (#322)#377leynos wants to merge 1 commit into
Conversation
Add the generative coverage requested for the invariants introduced or extended by PR #315 (`proptest` was already a dev-dependency): - Cycle detection (`src/ir/cycle_analyse_tests.rs`): graphs built from arbitrary forward edges never report a cycle; any graph with a back-edge (closed over a guaranteed chain) always does; missing-dependency records are exactly the edges whose targets are absent from the target map; and `analyse` results are stable across arbitrary `HashMap` insertion orderings. - Ninja separator ordering (`tests/ninja_property_tests.rs`): for any `BuildEdge` with non-empty `inputs`, `implicit_deps`, and `order_only_deps`, the emitted build line is exactly `inputs | implicit || order-only`; the `|` separator is absent when `implicit_deps` is empty while `||` is still emitted. - Command interpolation (`src/ir/cmd_interpolate.rs`): `$in`/`$out` and `__NETSUKE_*_PLACEHOLDER__` tokens inside backtick-delimited regions survive verbatim for arbitrary input/output lists, and placeholders outside backticks are always replaced with the joined lists.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Reviewer's GuideAdds property-based tests for cycle analysis, Ninja build-line separator ordering, and command interpolation, including helper generators and regression seeds, to strengthen invariants around cycles, missing dependencies, determinism across HashMap insertion order, Ninja output formatting, and placeholder handling within and outside backticks. Flow diagram for command interpolation behavior with backticks and placeholdersflowchart LR
Tmpl["template with tokens ($in, $out, __NETSUKE_INS_PLACEHOLDER__, __NETSUKE_OUTS_PLACEHOLDER__)"]
Ins["ins: list of input paths"]
Outs["outs: list of output paths"]
Tmpl --> IC["interpolate_command(template, ins, outs)"]
Ins --> IC
Outs --> IC
IC --> BQ{"token inside backticks?"}
BQ -- "yes" --> Preserve["leave token text unchanged in output"]
Preserve --> Cmd1["command equals original template"]
BQ -- "no" --> PH{"is token a __NETSUKE_*_PLACEHOLDER__?"}
PH -- "yes" --> Replace["replace placeholder with joined ins/outs (space separated)"]
Replace --> Cmd2["command contains expanded paths and no PLACEHOLDER text"]
PH -- "no" --> Other["process other tokens (e.g. $in, $out) according to existing rules"]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary
Closes #322
Adds the three groups of generative coverage the issue requests (
proptestwas already a dev-dependency, so noCargo.tomlchange was needed):Cycle detection (
src/ir/cycle_analyse_tests.rs):HashMapinsertion orderings (prop_shuffle).Ninja separator ordering (
tests/ninja_property_tests.rs): for arbitrary non-emptyinputs/implicit_deps/order_only_deps, the build line is exactlybuild out: act <inputs> | <implicit> || <order-only>; with emptyimplicit_depsthe|separator is absent while||remains.Command interpolation (
src/ir/cmd_interpolate.rs):$in,$out, and both__NETSUKE_*_PLACEHOLDER__tokens inside backticks survive verbatim for arbitrary path lists; placeholders outside backticks are always replaced with the joined lists.Existing canonicalisation/detector property tests already covered determinism; these additions fill the gaps the issue identified.
Validation
make check-fmt/make lint/make test— pass (38 suites; newninja_property_testsbinary included)🤖 Generated with Claude Code
Summary by Sourcery
Add property-based tests to strengthen guarantees around cycle analysis, Ninja separator ordering, and command interpolation behavior.
Enhancements:
Tests:
|and||separators in build lines.Chores: