@@ -765,18 +765,19 @@ fn override_self() {
765
765
766
766
let p = project ( "foo" ) ;
767
767
let root = p. root ( ) . clone ( ) ;
768
- let p = p. file (
769
- ".cargo/config" ,
770
- & format ! (
771
- r#"
772
- paths = ['{}']
773
- "# ,
774
- root. display( )
775
- ) ,
776
- ) . file (
777
- "Cargo.toml" ,
768
+ let p =
769
+ p. file (
770
+ ".cargo/config" ,
778
771
& format ! (
779
772
r#"
773
+ paths = ['{}']
774
+ "# ,
775
+ root. display( )
776
+ ) ,
777
+ ) . file (
778
+ "Cargo.toml" ,
779
+ & format ! (
780
+ r#"
780
781
[package]
781
782
782
783
name = "foo"
@@ -787,12 +788,12 @@ fn override_self() {
787
788
path = '{}'
788
789
789
790
"# ,
790
- bar. root( ) . display( )
791
- ) ,
792
- )
793
- . file ( "src/lib.rs" , "" )
794
- . file ( "src/main.rs" , "fn main() {}" )
795
- . build ( ) ;
791
+ bar. root( ) . display( )
792
+ ) ,
793
+ )
794
+ . file ( "src/lib.rs" , "" )
795
+ . file ( "src/main.rs" , "fn main() {}" )
796
+ . build ( ) ;
796
797
797
798
assert_that ( p. cargo ( "build" ) , execs ( ) . with_status ( 0 ) ) ;
798
799
}
@@ -1177,6 +1178,75 @@ Caused by:
1177
1178
) ;
1178
1179
}
1179
1180
1181
+ #[ test]
1182
+ fn cargo_update_downgrade_dependencies ( ) {
1183
+ // https://github.com/rust-lang/cargo/issues/5529
1184
+
1185
+ Package :: new ( "x" , "1.0.3" ) . publish ( ) ;
1186
+ Package :: new ( "x" , "1.0.2" ) . publish ( ) ;
1187
+ Package :: new ( "x" , "1.0.1" ) . publish ( ) ;
1188
+ Package :: new ( "x" , "1.0.0" ) . publish ( ) ;
1189
+ Package :: new ( "x" , "0.9.1" ) . publish ( ) ;
1190
+ Package :: new ( "x" , "0.9.0" ) . publish ( ) ;
1191
+
1192
+ let p = project ( "foo" )
1193
+ . file (
1194
+ "Cargo.toml" ,
1195
+ r#"
1196
+ [workspace]
1197
+ members = ["a", "b", "c"]
1198
+ "# ,
1199
+ )
1200
+ . file ( "a/src/lib.rs" , "" )
1201
+ . file (
1202
+ "a/Cargo.toml" ,
1203
+ r#"
1204
+ [package]
1205
+ name = "a"
1206
+ version = "0.1.0"
1207
+
1208
+ [dependencies]
1209
+ x="0.9"
1210
+ "# ,
1211
+ )
1212
+ . file ( "b/src/lib.rs" , "" )
1213
+ . file (
1214
+ "b/Cargo.toml" ,
1215
+ r#"
1216
+ [package]
1217
+ name = "b"
1218
+ version = "0.1.0"
1219
+
1220
+ [dependencies]
1221
+ x=">= 0.9, < 2.0"
1222
+ "# ,
1223
+ )
1224
+ . file ( "c/src/lib.rs" , "" )
1225
+ . file (
1226
+ "c/Cargo.toml" ,
1227
+ r#"
1228
+ [package]
1229
+ name = "c"
1230
+ version = "0.1.0"
1231
+
1232
+ [dependencies]
1233
+ x="1.0"
1234
+ "# ,
1235
+ )
1236
+ . build ( ) ;
1237
+
1238
+ // Generate a lock file
1239
+ assert_that ( p. cargo ( "generate-lockfile" ) , execs ( ) . with_status ( 0 ) ) ;
1240
+
1241
+ let good_lock = fs:: read_to_string ( & p. root ( ) . join ( "Cargo.lock" ) ) . unwrap ( ) ;
1242
+
1243
+ assert_that ( p. cargo ( "update -p c" ) , execs ( ) . with_status ( 0 ) ) ;
1244
+
1245
+ let new_lock = fs:: read_to_string ( & p. root ( ) . join ( "Cargo.lock" ) ) . unwrap ( ) ;
1246
+
1247
+ assert_eq ! ( good_lock, new_lock) ;
1248
+ }
1249
+
1180
1250
#[ test]
1181
1251
fn invalid_path_dep_in_workspace_with_lockfile ( ) {
1182
1252
Package :: new ( "bar" , "1.0.0" ) . publish ( ) ;
0 commit comments