Skip to content

Commit 0c263ae

Browse files
committed
Expect one yarn reader's warning outside the root
A yarn classic file: directory copy outside the project root is now named by the yarn rewriter, with the same redirect_yarn_classic_directory_skipped warning an in-root copy gets, instead of the engine's generic redirect_copy_unpatched fallback. The e2e now asserts that code, and that the copy is named exactly once. The rewriter test's doc says what it compares: which package the copy holds. Refs #1951 Assisted-by: Claude Code:claude-opus-5-5
1 parent 682488b commit 0c263ae

2 files changed

Lines changed: 26 additions & 12 deletions

File tree

‎crates/socket-patch-cli/tests/e2e_redirect_yarn_classic_build.rs‎

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,9 +1542,10 @@ async fn classic_file_directory_copy_under_another_name_is_named_and_not_atteste
15421542
/// #1516: the #1236 copy, but from a directory OUTSIDE the project root
15431543
/// (`"lp2": "file:../ext/lpdir"`, shared code in a non-workspace
15441544
/// monorepo). yarn 1 installs it into `node_modules/lp2` all the same, so
1545-
/// it stays unpatched. `scan --mode hosted` must name the copy
1546-
/// (`redirect_copy_unpatched`), and neither its in-run VEX nor a lock-only
1547-
/// `vex` may attest left-pad not_affected.
1545+
/// it stays unpatched. `scan --mode hosted` must name the copy exactly as
1546+
/// it names an in-root one (`redirect_yarn_classic_directory_skipped`,
1547+
/// read through the reader vendored and VEX use, #1951), once, and neither
1548+
/// its in-run VEX nor a lock-only `vex` may attest left-pad not_affected.
15481549
#[tokio::test(flavor = "multi_thread")]
15491550
#[serial_test::serial]
15501551
async fn classic_outside_root_copy_under_another_name_is_named_and_not_attested() {
@@ -1635,11 +1636,22 @@ async fn classic_outside_root_copy_under_another_name_is_named_and_not_attested(
16351636
lock.contains(&format!("{UUID}/{DEP}-{DEP_VERSION}.tgz")),
16361637
"the registry left-pad block must still be pinned:\n{lock}"
16371638
);
1638-
assert!(
1639-
env.to_string().contains("redirect_copy_unpatched"),
1640-
"the outside-root copy must be named: {env}"
1639+
let naming: Vec<&str> = env["warnings"]
1640+
.as_array()
1641+
.into_iter()
1642+
.flatten()
1643+
.filter(|w| {
1644+
w["detail"]
1645+
.as_str()
1646+
.is_some_and(|d| d.contains("lp2@file:../ext/lpdir"))
1647+
})
1648+
.filter_map(|w| w["code"].as_str())
1649+
.collect();
1650+
assert_eq!(
1651+
naming,
1652+
["redirect_yarn_classic_directory_skipped"],
1653+
"the outside-root copy must be named once, as an in-root one is: {env}"
16411654
);
1642-
assert!(env.to_string().contains("lp2@file:../ext/lpdir"), "{env}");
16431655
let vex = std::fs::read_to_string(proj.join("out.vex.json")).unwrap_or_default();
16441656
assert!(
16451657
!vex.contains("not_affected"),

‎crates/socket-patch-core/src/patch/redirect/mod.rs‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13751,10 +13751,12 @@ mod tests {
1375113751
}
1375213752
}
1375313753

13754-
/// #1951: the hosted rewriter names a yarn classic `file:` / url copy
13755-
/// through the same reader vendored and VEX use
13756-
/// ([`crate::formats::yarn::copy::classic_copy_ref`]), so the modes
13757-
/// make the same decision for every copy. yarn 1 installs
13754+
/// #1951: the hosted rewriter reads which package a yarn classic
13755+
/// `file:` / url copy holds through the same reader vendored and VEX use
13756+
/// ([`crate::formats::yarn::copy::classic_copy_ref`] and
13757+
/// [`crate::formats::yarn::copy::CopyRef::identity`]), so the modes
13758+
/// identify the same copies. (A copy no reader identifies is a separate
13759+
/// rule: vendored keeps it as a possible copy, #1516.) yarn 1 installs
1375813760
/// `file:../ext/lpdir` from outside the root as readily as from inside
1375913761
/// it, so that copy is read and named; an absolute `file:` path is never
1376013762
/// read (a lock is untrusted input, #1516); a codeload tarball names no
@@ -13792,7 +13794,7 @@ mod tests {
1379213794
false,
1379313795
),
1379413796
] {
13795-
// What vendored and VEX decide for this copy.
13797+
// The package vendored and VEX identify this copy as.
1379613798
let pats = vec![patterns.to_string()];
1379713799
let vendored = classic_copy_ref(&pats, resolved).and_then(|copy| {
1379813800
let bytes = copy

0 commit comments

Comments
 (0)