@@ -2914,3 +2914,91 @@ Caused by:
29142914 )
29152915 . run ( ) ;
29162916}
2917+
2918+ #[ cargo_test]
2919+ fn patched_reexport_stays_locked ( ) {
2920+ // Patch example where you emulate a semver-incompatible patch via a re-export.
2921+ // Testing an issue where the lockfile does not stay locked after a new version is published.
2922+ Package :: new ( "bar" , "1.0.0" ) . publish ( ) ;
2923+ Package :: new ( "bar" , "2.0.0" ) . publish ( ) ;
2924+ Package :: new ( "bar" , "3.0.0" ) . publish ( ) ;
2925+
2926+ let p = project ( )
2927+ . file (
2928+ "Cargo.toml" ,
2929+ r#"
2930+ [workspace]
2931+
2932+
2933+ [package]
2934+ name = "foo"
2935+
2936+ [dependencies]
2937+ bar1 = {package="bar", version="1.0.0"}
2938+ bar2 = {package="bar", version="2.0.0"}
2939+
2940+ [patch.crates-io]
2941+ bar1 = { package = "bar", path = "bar-1-as-3" }
2942+ bar2 = { package = "bar", path = "bar-2-as-3" }
2943+ "# ,
2944+ )
2945+ . file ( "src/lib.rs" , "" )
2946+ . file (
2947+ "bar-1-as-3/Cargo.toml" ,
2948+ r#"
2949+ [package]
2950+ name = "bar"
2951+ version = "1.0.999"
2952+
2953+ [dependencies]
2954+ bar = "3.0.0"
2955+ "# ,
2956+ )
2957+ . file ( "bar-1-as-3/src/lib.rs" , "" )
2958+ . file (
2959+ "bar-2-as-3/Cargo.toml" ,
2960+ r#"
2961+ [package]
2962+ name = "bar"
2963+ version = "2.0.999"
2964+
2965+ [dependencies]
2966+ bar = "3.0.0"
2967+ "# ,
2968+ )
2969+ . file ( "bar-2-as-3/src/lib.rs" , "" )
2970+ . build ( ) ;
2971+
2972+ p. cargo ( "tree" )
2973+ . with_stdout (
2974+ "\
2975+ foo v0.0.0 ([ROOT]/foo)
2976+ ├── bar v1.0.999 ([ROOT]/foo/bar-1-as-3)
2977+ │ └── bar v3.0.0
2978+ └── bar v2.0.999 ([ROOT]/foo/bar-2-as-3)
2979+ └── bar v3.0.0
2980+ " ,
2981+ )
2982+ . run ( ) ;
2983+
2984+ std:: fs:: copy (
2985+ p. root ( ) . join ( "Cargo.lock" ) ,
2986+ p. root ( ) . join ( "Cargo.lock.orig" ) ,
2987+ )
2988+ . unwrap ( ) ;
2989+
2990+ Package :: new ( "bar" , "3.0.1" ) . publish ( ) ;
2991+ p. cargo ( "tree" )
2992+ . with_stdout (
2993+ "\
2994+ foo v0.0.0 ([ROOT]/foo)
2995+ ├── bar v1.0.999 ([ROOT]/foo/bar-1-as-3)
2996+ │ └── bar v3.0.1
2997+ └── bar v2.0.999 ([ROOT]/foo/bar-2-as-3)
2998+ └── bar v3.0.1
2999+ " ,
3000+ )
3001+ . run ( ) ;
3002+
3003+ assert_ne ! ( p. read_file( "Cargo.lock" ) , p. read_file( "Cargo.lock.orig" ) ) ;
3004+ }
0 commit comments