@@ -3012,6 +3012,84 @@ async fn hosted_pnpm_file_tarball_copy_is_named() {
30123012 . await ;
30133013}
30143014
3015+ /// #2009: the registry release is a pnpm config dependency (the env
3016+ /// lockfile document) and the project document installs only a `file:`
3017+ /// copy of the same `name@version`. The scan pins the config dependency,
3018+ /// and names the project's copy with `redirect_copy_unpatched`, since a
3019+ /// VEX statement covers the release, not one install tree. Before, the
3020+ /// env pin's copy check compared trees, so the copy went unnamed.
3021+ #[ tokio:: test]
3022+ #[ serial]
3023+ async fn hosted_pnpm_config_dependency_names_the_projects_file_copy ( ) {
3024+ let server = MockServer :: start ( ) . await ;
3025+ mock_discovery ( & server) . await ;
3026+ mock_reference ( & server) . await ;
3027+
3028+ let tmp = tempfile:: tempdir ( ) . unwrap ( ) ;
3029+ let root = tmp. path ( ) ;
3030+ let copy_key = format ! ( "file:forks/{NAME}" ) ;
3031+ write_file_copy_project (
3032+ root,
3033+ & copy_key,
3034+ & format ! ( " resolution: {{directory: forks/{NAME}, type: directory}}\n " ) ,
3035+ & format ! ( "file:../../forks/{NAME}" ) ,
3036+ ) ;
3037+ std:: fs:: remove_dir_all ( root. join ( "packages" ) . join ( "a" ) ) . unwrap ( ) ;
3038+ std:: fs:: write (
3039+ root. join ( "pnpm-lock.yaml" ) ,
3040+ format ! (
3041+ "---
3042+ lockfileVersion: '9.0'
3043+
3044+ importers:
3045+
3046+ .:
3047+ configDependencies:
3048+ {NAME}:
3049+ specifier: {VERSION}
3050+ version: {VERSION}
3051+
3052+ packages:
3053+
3054+ {NAME}@{VERSION}:
3055+ resolution: {{integrity: {UPSTREAM_SHA512}}}
3056+
3057+ ---
3058+ lockfileVersion: '9.0'
3059+
3060+ importers:
3061+ .: {{}}
3062+ packages/b:
3063+ dependencies:
3064+ {NAME}:
3065+ specifier: file:../../forks/{NAME}
3066+ version: {copy_key}
3067+
3068+ packages:
3069+ {NAME}@{copy_key}:
3070+ resolution: {{directory: forks/{NAME}, type: directory}}
3071+
3072+ snapshots:
3073+ {NAME}@{copy_key}: {{}}
3074+ "
3075+ ) ,
3076+ )
3077+ . unwrap ( ) ;
3078+
3079+ let ( code, doc) = run_hosted_json ( root, & server. uri ( ) ) ;
3080+ assert_eq ! ( code, Some ( 0 ) , "{doc}" ) ;
3081+ let lock = std:: fs:: read_to_string ( root. join ( "pnpm-lock.yaml" ) ) . unwrap ( ) ;
3082+ assert ! (
3083+ lock. contains( & format!( "tarball: {HOSTED_URL}" ) ) ,
3084+ "the config dependency is pinned: {lock}"
3085+ ) ;
3086+ let text = doc. to_string ( ) ;
3087+ assert ! (
3088+ text. contains( "redirect_copy_unpatched" ) && text. contains( & format!( "`{NAME}@{copy_key}`" ) ) ,
3089+ "the project's copy is named: {doc:#}"
3090+ ) ;
3091+ }
3092+
30153093/// The #935 workspace: member `a` depends on the registry release, member
30163094/// `b` on the `file:` copy `copy_key` (spelled `spec` in its manifest).
30173095fn write_file_copy_project ( root : & Path , copy_key : & str , copy_entry : & str , spec : & str ) {
0 commit comments