@@ -37,8 +37,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
37
37
"checksum foo 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "[..]"
38
38
"# ;
39
39
40
- let old_lockfile = r#"
41
- [root]
40
+ let old_lockfile =
41
+ r#" [root]
42
42
name = "bar"
43
43
version = "0.0.1"
44
44
dependencies = [
@@ -62,9 +62,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
62
62
foo = "0.1.0"
63
63
"# )
64
64
. file ( "src/lib.rs" , "" )
65
- . file ( "Cargo.lock" , old_lockfile) ;
66
-
67
- let p = p. build ( ) ;
65
+ . file ( "Cargo.lock" , old_lockfile)
66
+ . build ( ) ;
68
67
69
68
assert_that ( p. cargo ( cargo_command) ,
70
69
execs ( ) . with_status ( 0 ) ) ;
@@ -77,6 +76,54 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
77
76
assert_eq ! ( lock. lines( ) . count( ) , expected_lockfile. lines( ) . count( ) ) ;
78
77
}
79
78
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
+
80
127
#[ test]
81
128
fn totally_wild_checksums_works ( ) {
82
129
Package :: new ( "foo" , "0.1.0" ) . publish ( ) ;
0 commit comments