Repository navigation
test(support): reject a stale oc-rsync binary instead of reporting it as a regression - #7385
Merged
Merged
Conversation
…writes Cargo emits `<profile>/<name>.d` beside the uplifted binary only when that binary is a primary target of the invocation, as it is under `cargo build`. A `cargo test` / nextest build uplifts the binary but writes no `.d` there, and that is how every CI cell and the documented local workflow build it - so the freshness guard aborted with "cannot read Cargo's dependency file" on a binary that was perfectly current. Fall back to the per-unit dependency file in `deps/`, which every build writes. `deps/` holds one unit per feature set under its own hash, and the uplifted binary is a hard link of exactly one of them, so the unit is selected by file identity rather than by a name whose hash encodes a feature set this crate cannot see. The real-binary test now resolves through the same helper, making it the gate that proves a dependency file is findable where CI actually runs instead of leaving that an assumption.
`MetadataExt::file_index` and `volume_serial_number` sit behind the unstable `windows_by_handle` feature, so the inode-equivalent comparison did not compile on Windows at all - every Windows cell failed with E0658. Compare length and write time there instead. A hard link shares both by construction, and so does the copy Cargo falls back to when linking is unavailable, since it preserves the timestamp. Because that is a weaker discriminator than an inode, the match must now be unique: two units that look alike refuse rather than pick one, since the wrong unit's dependency list can name a `cfg`-gated source this binary never compiled, which would demand a rebuild Cargo has no reason to perform. Unix keeps the exact `(dev, ino)` pair; the uniqueness rule is shared and costs it nothing, because only one `deps/` entry can carry the inode.
…weaker one The per-unit `deps/<crate>-<hash>.d` is not a substitute for the dependency file Cargo writes beside the uplifted binary. Measured on this workspace: the per-unit file names 3 sources - `src/bin/oc-rsync.rs` and the two files it `include!`s - while the aggregated file names 1451, every path dependency included. Checking against the per-unit list would therefore pass while the binary was stale with respect to engine, transfer, cli, filters and every other crate, which is exactly the class this guard exists to catch: all three prior misdiagnoses were edits in those crates. That is worse than no check - it reads as coverage and cannot fail for the reason it was built. So the check is now active only when the aggregated file is present, which is what `cargo build` writes, and does nothing when it is absent. The cost is stated in the module docs rather than hidden: a binary built solely by a workspace test run and then reused by a per-crate run is unguarded until one `cargo build --bin oc-rsync` arms it. CI does not need it, because there Cargo builds the binary in the same invocation that runs the tests. Found by the test added to prove the assumption rather than assert it: it resolved a dependency file and parsed 10 deps where the aggregated one has 1451. The assertion stays, and now also pins that the file read is the aggregated one.
Removing the deps/ fallback left the one test that reads a real dependency file unable to run anywhere automatic: it needs the aggregated file, which only `cargo build` writes, so it early-returns in CI and in any worktree that has not built the binary. Nothing then pinned the parser against Cargo's actual format. Adds one line of real `cargo build` output as a fixture - abridged to a representative entry per category, checkout root replaced, verbatim in every respect the parser can observe: one line, one target, space-separated absolute paths, no continuations (measured: the real file is a single line of 1461 entries, unlike the per-unit file's two target lines plus phony lines). Asserts the properties that matter and would otherwise go unchecked: the target is not parsed as one of its own sources, `.git` metadata is filtered, and non-`.rs` entries survive - a manifest or an `include!`d README edit is a real rebuild trigger, so dropping them would blind the guard to it. RED proven by deleting the `.git` filter: this test and its synthetic sibling both fail.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
… as a regression (#7385) * test(support): reject a stale oc-rsync binary instead of reporting it as a regression * fix(support): backslash escapes only a space in a Cargo dependency file * chore: sync Cargo.lock * fix(support): resolve the dependency file a test-mode build actually writes Cargo emits `<profile>/<name>.d` beside the uplifted binary only when that binary is a primary target of the invocation, as it is under `cargo build`. A `cargo test` / nextest build uplifts the binary but writes no `.d` there, and that is how every CI cell and the documented local workflow build it - so the freshness guard aborted with "cannot read Cargo's dependency file" on a binary that was perfectly current. Fall back to the per-unit dependency file in `deps/`, which every build writes. `deps/` holds one unit per feature set under its own hash, and the uplifted binary is a hard link of exactly one of them, so the unit is selected by file identity rather than by a name whose hash encodes a feature set this crate cannot see. The real-binary test now resolves through the same helper, making it the gate that proves a dependency file is findable where CI actually runs instead of leaving that an assumption. * docs(support): name the two places Cargo writes a dependency file * fix(support): select the deps unit with APIs that are stable on Windows `MetadataExt::file_index` and `volume_serial_number` sit behind the unstable `windows_by_handle` feature, so the inode-equivalent comparison did not compile on Windows at all - every Windows cell failed with E0658. Compare length and write time there instead. A hard link shares both by construction, and so does the copy Cargo falls back to when linking is unavailable, since it preserves the timestamp. Because that is a weaker discriminator than an inode, the match must now be unique: two units that look alike refuse rather than pick one, since the wrong unit's dependency list can name a `cfg`-gated source this binary never compiled, which would demand a rebuild Cargo has no reason to perform. Unix keeps the exact `(dev, ino)` pair; the uniqueness rule is shared and costs it nothing, because only one `deps/` entry can carry the inode. * fix(support): drop the deps/ fallback - it was a false oracle, not a weaker one The per-unit `deps/<crate>-<hash>.d` is not a substitute for the dependency file Cargo writes beside the uplifted binary. Measured on this workspace: the per-unit file names 3 sources - `src/bin/oc-rsync.rs` and the two files it `include!`s - while the aggregated file names 1451, every path dependency included. Checking against the per-unit list would therefore pass while the binary was stale with respect to engine, transfer, cli, filters and every other crate, which is exactly the class this guard exists to catch: all three prior misdiagnoses were edits in those crates. That is worse than no check - it reads as coverage and cannot fail for the reason it was built. So the check is now active only when the aggregated file is present, which is what `cargo build` writes, and does nothing when it is absent. The cost is stated in the module docs rather than hidden: a binary built solely by a workspace test run and then reused by a per-crate run is unguarded until one `cargo build --bin oc-rsync` arms it. CI does not need it, because there Cargo builds the binary in the same invocation that runs the tests. Found by the test added to prove the assumption rather than assert it: it resolved a dependency file and parsed 10 deps where the aggregated one has 1451. The assertion stays, and now also pins that the file read is the aggregated one. * test(support): pin the parser against genuine cargo dep-info output Removing the deps/ fallback left the one test that reads a real dependency file unable to run anywhere automatic: it needs the aggregated file, which only `cargo build` writes, so it early-returns in CI and in any worktree that has not built the binary. Nothing then pinned the parser against Cargo's actual format. Adds one line of real `cargo build` output as a fixture - abridged to a representative entry per category, checkout root replaced, verbatim in every respect the parser can observe: one line, one target, space-separated absolute paths, no continuations (measured: the real file is a single line of 1461 entries, unlike the per-unit file's two target lines plus phony lines). Asserts the properties that matter and would otherwise go unchecked: the target is not parsed as one of its own sources, `.git` metadata is filtered, and non-`.rs` entries survive - a manifest or an `include!`d README edit is a real rebuild trigger, so dropping them would blind the guard to it. RED proven by deleting the `.git` filter: this test and its synthetic sibling both fail. --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
crates/test-support/src/bin_path.rsopens by stating the invariant it enforces:It checks the binary exists and is executable. It never checks it is current.
Cargo builds the
oc-rsync[[bin]]from the workspace root package, so a per-crate run(
cargo nextest run -p cli) compiles that crate's test binaries and leavesoc-rsyncuntouched. The tests then exercise whatever revision was built last, and the failure
presents as a behavioural regression: tests red, diff innocent.
That is not hypothetical. Three
cli::dir_merge_x_modifiercells were failing withagainst a four-day-old binary. The same fixture run against a freshly built binary matches
upstream 3.5.0 exactly, in all four cells (
: .rules/:x .rules, flat and nested), onboth Linux and macOS. There was no filter defect - only a stale build.
Fix
workspace_binnow also asserts the binary is newer than every source Cargo compiled itfrom, read from Cargo's own
<binary>.ddependency file (--emit=dep-info) rather than aheuristic scan of the tree. On a stale binary:
Two deliberate rules, both pinned by tests:
.gitentries are ignored. Build scripts that embed revision metadata record.git/HEAD; it changes on every commit and fetch without altering a byte of programinput, so honouring it would demand a relink after each commit.
.dpanics. Silently passing when the evidence is absent is thevacuous-skip pattern this module already refuses for a missing binary.
A dependency Cargo recorded but that has since been deleted is not treated as stale - that
rebuild is Cargo's business.
Verification
target/debug/oc-rsyncturns the threedir_merge_x_modifiercells into the freshnesspanic quoting
Cargo.toml; rebuilding returns3 tests run: 3 passed.\as a universal escape, which turnsC:\src\lib.rsintoC:srclib.rs- a path thatnever exists and therefore always looks fresh, disabling the guard on Windows. rustc
escapes only spaces; corrected in the second commit, with the Windows drive-letter and
escaped-space cases pinned.
a fresh-binary acceptance, without which a guard that rejects everything would also pass.
cargo fmt --all -- --checkclean;cargo clippy --workspace --all-targets --all-features --no-deps -- -D warningszero diagnostics;-p test-support52/52 on Linux.Notes
OcRsyncCliRunner::newresolves throughlocate_workspace_binary, whose documentedcontract is to return
Optionso a test can self-skip. It therefore bypasses this guard.Changing that contract is a separate question and is left alone here.