Repository navigation
Test the undo of a Maven pin that another build's file holds too - #2171
Conversation
…s too
A hosted pin is one patch of one package in every file that wires it,
and each file format has a restorer of its own, which is handed the
pins that have a file of its format together with that format's files.
When hosted mode learned Maven reactors and `${property}` versions
(#2114), the Maven restorer went from a loop over its files to a loop
over its pins, and took every file of a pin for one of its poms. A pin
with a file the Maven restorer was not handed was then passed over
without a refusal: nothing was restored in pom.xml or under .mvn, while
the restorer of the other file took its part out and the run reported
the pin as restored.
A checkout that sbt builds beside Maven is such a case: the patch is
pinned in socket-patch.sbt and in pom.xml, and `rollback` (or `remove`)
exits 0, reports one rolled-back patch, and leaves pom.xml and the two
.mvn files pinned. The hosted Gradle index beside a pom.xml is a second
file of the same kind (read, not run).
The poms of a pin are now those of its files that the Maven restorer
was handed. A pin that only poms hold has all its files there, so it is
read exactly as before: a reactor's pin is restored in every pom that
carries part of it or in none, and a pom that cannot be read refuses
it. The existing tests of the Maven undo pass unedited.
The new test runs discovery and the undo over the existing fixture
sbt/redirect/pom-also-present: one pin with pom.xml and
socket-patch.sbt, and the tree is byte for byte its input afterwards.
Without the fix it fails, and no other test of the core suite does.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Tests only: no product code changes. The fix before this commit lets the Maven restorer act on a hosted pin that another build's file holds too. These tests hold what follows from two restorers acting on one pin. The sbt golden harness undid each wiring case with hand-built pins that listed only socket-patch.sbt, and asserted every other file untouched. For the case pom-also-present it therefore asserted that the pinned pom.xml stays pinned, which is why the goldens never saw the defect. It now restores the pins discovery finds in the wired tree, as `rollback` does, and compares the whole tree with the case's input. The ten wiring cases that create the file pass; without the fix pom-also-present fails. In upstream/maven.rs: - The hosted Gradle index beside a pom.xml is now run, not only read: one scan wires a Gradle build and the pom beside it, discovery gives one pin with both files, and the undo puts the tree back byte for byte. It is a second row of the existing two-build test. - A pin is restored in every file that wires it or in none. With an edited socket-patch.sbt the sbt restorer refuses, and pom.xml and the .mvn files stay pinned. With a pom that names the patched version outside a dependency the Maven restorer refuses, and socket-patch.sbt keeps its row. Nothing is written in either case. In the CLI, `vendor` over a hosted pin that pom.xml and socket-patch.sbt both hold. The takeover restores the whole pin, so with the fix pom.xml is the upstream one after one run, the sbt build is vendored, and the run gives the advisory vendor_sbt_pom_ignored. Before the fix the same run left pom.xml pinned, and a second `vendor` run unpinned it. The test holds the new behaviour; the takeover itself is not changed. Every new expectation fails with the fix taken out, except the half where the sbt restorer refuses: that one fails when the driver writes the files of a pass in which a pin was refused. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ild-pin # Conflicts: # crates/socket-patch-core/src/patch/redirect/upstream/maven.rs
PR SummaryLow Risk Overview The sbt golden harness no longer rolls back with hand-built pins that only list Maven upstream tests add a Gradle+pom scenario beside the existing sbt+pom fixture, extract A new CLI e2e runs Reviewed by Cursor Bugbot for commit 108f5be. Configure here. |
No user-visible change.
What this is
Tests only. The fix this pull request first carried is on
mainalready: it landed with #2163, which needed it.rollbackandremoverestorepom.xmlfor a hosted Maven patch that a second build of the same checkout pins too (an sbt build, a Gradle build, a Bazel hub). Before that fix they left the pom pinned and reported success.What is left here are the tests a code review of that fix asked for. They hold what follows when two restorers act on one pin. After the merge with
mainthe diff is three files, +161 −52, none of it product code.The tests
crates/socket-patch-core/tests/redirect_sbt_golden.rs). It undid each wiring case with hand-built pins that listed onlysocket-patch.sbtand asserted every other file untouched. For the casepom-also-presentit therefore asserted that the pinnedpom.xmlstays pinned, which is why the goldens never saw the defect. It now restores the pins that discovery finds in the wired tree, asrollbackdoes, and compares the whole tree with the case's input.upstream/maven.rs). One scan wires a Gradle build and thepom.xmlbeside it, discovery gives one pin with both files, and the undo puts the tree back byte for byte. The fix's commit only read this case; now it runs.upstream/maven.rs). A pin is restored in every file that wires it or in none. With an editedsocket-patch.sbtthe sbt restorer refuses, andpom.xmland the.mvnfiles stay pinned. With a pom that names the patched version outside a dependency the Maven restorer refuses, andsocket-patch.sbtkeeps its row. Nothing is written in either case.vendorover such a pin (crates/socket-patch-cli/tests/e2e_sbt_vendor.rs). The takeover restores the whole pin, so after one runpom.xmlis the upstream one, the sbt build is vendored, and the run gives the advisoryvendor_sbt_pom_ignored. Before the fix the same run leftpom.xmlpinned and a second run unpinned it. The takeover itself is not changed here.What was run
On macOS arm64, on top of current
main: the unit tests of the Maven restorer (25 passed), the sbt golden target,--test e2e_sbt_vendor(21 passed) andcargo clippy --workspace --all-features -- -D warnings.When the commit was written, every new expectation failed with the fix taken out, except the half where the sbt restorer refuses: that one fails when the driver writes the files of a pass in which a pin was refused. Those runs were not repeated after the merge with
main.Left open
upstream/mod.rsthe set of handled pins is a union over formats, so when one format's restorer silently skips a pin and another format handles it, the run reports the pin restored. That is how this defect stayed unseen. Refusing every such pin would turn the next defect of this kind into a refusal, but it changes behaviour for other ecosystems and wants a pull request of its own.<module>child/custom-pom.xml</module>) is classed as an unsupported file, and its pin always refuses. That was so before the fix and is unchanged.🤖 Generated with Claude Code