@@ -37,8 +37,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
3737"checksum foo 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "[..]"
3838"# ;
3939
40- let old_lockfile = r#"
41- [root]
40+ let old_lockfile =
41+ r#" [root]
4242name = "bar"
4343version = "0.0.1"
4444dependencies = [
@@ -62,9 +62,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
6262 foo = "0.1.0"
6363 "# )
6464 . file ( "src/lib.rs" , "" )
65- . file ( "Cargo.lock" , old_lockfile) ;
66-
67- let p = p. build ( ) ;
65+ . file ( "Cargo.lock" , old_lockfile)
66+ . build ( ) ;
6867
6968 assert_that ( p. cargo ( cargo_command) ,
7069 execs ( ) . with_status ( 0 ) ) ;
@@ -77,6 +76,54 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
7776 assert_eq ! ( lock. lines( ) . count( ) , expected_lockfile. lines( ) . count( ) ) ;
7877}
7978
79+
80+ #[ test]
81+ fn frozen_flag_preserves_old_lockfile ( ) {
82+ Package :: new ( "foo" , "0.1.0" ) . publish ( ) ;
83+
84+ let old_lockfile =
85+ r#"[root]
86+ name = "bar"
87+ version = "0.0.1"
88+ dependencies = [
89+ "foo 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
90+ ]
91+
92+ [[package]]
93+ name = "foo"
94+ version = "0.1.0"
95+ source = "registry+https://github.com/rust-lang/crates.io-index"
96+
97+ [metadata]
98+ "checksum foo 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f9e0a16bdf5c05435698fa27192d89e331b22a26a972c34984f560662544453b"
99+ "# ;
100+
101+ let p = project ( "bar" )
102+ . file ( "Cargo.toml" , r#"
103+ [project]
104+ name = "bar"
105+ version = "0.0.1"
106+ authors = []
107+
108+ [dependencies]
109+ foo = "0.1.0"
110+ "# )
111+ . file ( "src/lib.rs" , "" )
112+ . file ( "Cargo.lock" , old_lockfile)
113+ . build ( ) ;
114+
115+ assert_that ( p. cargo ( "build" ) . arg ( "--locked" ) ,
116+ execs ( ) . with_status ( 0 ) ) ;
117+
118+ let lock = p. read_lockfile ( ) ;
119+ for ( l, r) in old_lockfile. lines ( ) . zip ( lock. lines ( ) ) {
120+ assert ! ( lines_match( l, r) , "Lines differ:\n {}\n \n {}" , l, r) ;
121+ }
122+
123+ assert_eq ! ( lock. lines( ) . count( ) , old_lockfile. lines( ) . count( ) ) ;
124+ }
125+
126+
80127#[ test]
81128fn totally_wild_checksums_works ( ) {
82129 Package :: new ( "foo" , "0.1.0" ) . publish ( ) ;
0 commit comments