From 07c26982666de3666ff43691d712c2fec343482f Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 22 Oct 2026 11:07:28 +0000 Subject: [PATCH] Skip cargo shapes on a failed --precise pin pin_patched_versions asserted when `cargo update --precise` failed and dropped cargo's stderr, so a crates.io blip during fixture setup failed the suite with only "cannot lock cfg-if@1.0.4" and the lock text (seen in test-release (2) of run 39745825228). generate-lockfile and the baseline build already soft-skip on the same class of failure. Return the failure with each `cargo update` stderr instead and route it through cargo_e2e_matrix::skip: optional legs (coverage, test-release) skip with the cause printed, while the required lock-v* legs still fail on it, now with cargo's error in the panic. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01WKXDFSSDxDgdAGiUGLKWQB --- .../tests/e2e_redirect_cargo_shapes.rs | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/crates/socket-patch-cli/tests/e2e_redirect_cargo_shapes.rs b/crates/socket-patch-cli/tests/e2e_redirect_cargo_shapes.rs index ac1e6732c..a394c7e2d 100644 --- a/crates/socket-patch-cli/tests/e2e_redirect_cargo_shapes.rs +++ b/crates/socket-patch-cli/tests/e2e_redirect_cargo_shapes.rs @@ -463,7 +463,10 @@ async fn run_shape(shape: Shape) -> Option<()> { ); return None; } - pin_patched_versions(&proj, &home, &shape.patches); + if let Err(why) = pin_patched_versions(&proj, &home, &shape.patches) { + let _ = cargo_e2e_matrix::skip(&suite, &why); + return None; + } // A lockless shape deletes its lock before the scan, so the lock-format // matrix has nothing to exercise; re-encoding it would also misfire when // every package is sourceless (a `[patch]` path override): v1 then has @@ -945,8 +948,11 @@ fn contest_after_scan(shape: &Shape, dep: &str, fresh: &Path, home: &Path, uri: } /// Pin each patched version: a caret requirement locks the newest -/// compatible release, which moves as crates.io publishes. -fn pin_patched_versions(proj: &Path, home: &Path, patches: &[Patch]) { +/// compatible release, which moves as crates.io publishes. `cargo update +/// --precise` reads the index like `generate-lockfile` does, so a failure +/// is reported (with cargo's stderr) for the caller to skip on, the same +/// as a failed `generate-lockfile`; required legs still fail on it. +fn pin_patched_versions(proj: &Path, home: &Path, patches: &[Patch]) -> Result<(), String> { for patch in patches { let lock = std::fs::read_to_string(proj.join("Cargo.lock")).unwrap(); let locked = cargo_e2e_matrix::parse_lock(&lock); @@ -956,6 +962,7 @@ fn pin_patched_versions(proj: &Path, home: &Path, patches: &[Patch]) { { continue; } + let mut errors = String::new(); let pinned = locked .iter() .filter(|p| p.name == patch.name) @@ -966,20 +973,24 @@ fn pin_patched_versions(proj: &Path, home: &Path, patches: &[Patch]) { }) .any(|p| { let spec = format!("{}@{}", p.name, p.version); - cargo( + let update = cargo( proj, &["update", "-p", &spec, "--precise", patch.version], home, - ) - .status - .success() + ); + if !update.status.success() { + errors += &format!("`cargo update -p {spec}`: {}", stderr(&update)); + } + update.status.success() }); - assert!( - pinned, - "cannot lock {}@{}:\n{lock}", - patch.name, patch.version - ); + if !pinned { + return Err(format!( + "cannot lock {}@{} (crates.io unreachable?):\n{errors}\n{lock}", + patch.name, patch.version + )); + } } + Ok(()) } fn helper_manifest(deps: &str) -> String {