@@ -1190,3 +1190,91 @@ rustdns.workspace = true
1190
1190
) )
1191
1191
. run ( ) ;
1192
1192
}
1193
+
1194
+ #[ cargo_test]
1195
+ fn update_only_members_with_workspace ( ) {
1196
+ let git_project = git:: new ( "rustdns" , |project| {
1197
+ project
1198
+ . file ( "Cargo.toml" , & basic_lib_manifest ( "rustdns" ) )
1199
+ . file ( "src/lib.rs" , "pub fn bar() {}" )
1200
+ } ) ;
1201
+
1202
+ let workspace_toml = format ! (
1203
+ r#"
1204
+ [workspace.package]
1205
+ version = "2.29.8"
1206
+ edition = "2021"
1207
+ publish = false
1208
+
1209
+ [workspace]
1210
+ members = [
1211
+ "crate2",
1212
+ "crate1",
1213
+ ]
1214
+ resolver = "2"
1215
+
1216
+ [workspace.dependencies]
1217
+ # Internal crates
1218
+ crate1 = {{ version = "*", path = "./crate1" }}
1219
+
1220
+ # External dependencies
1221
+ rustdns = {{ version = "0.5.0", default-features = false, git = "{}" }}
1222
+ "# ,
1223
+ git_project. url( )
1224
+ ) ;
1225
+ let p = project ( )
1226
+ . file ( "Cargo.toml" , & workspace_toml)
1227
+ . file (
1228
+ "crate2/Cargo.toml" ,
1229
+ r#"
1230
+ [package]
1231
+ name = "crate2"
1232
+ version.workspace = true
1233
+ edition.workspace = true
1234
+ publish.workspace = true
1235
+
1236
+ [dependencies]
1237
+ crate1.workspace = true
1238
+ "# ,
1239
+ )
1240
+ . file ( "crate2/src/main.rs" , "fn main() {}" )
1241
+ . file (
1242
+ "crate1/Cargo.toml" ,
1243
+ r#"
1244
+ [package]
1245
+ name = "crate1"
1246
+ version.workspace = true
1247
+ edition.workspace = true
1248
+ publish.workspace = true
1249
+
1250
+ [dependencies]
1251
+ rustdns.workspace = true
1252
+ "# ,
1253
+ )
1254
+ . file ( "crate1/src/lib.rs" , "pub foo() {}" )
1255
+ . build ( ) ;
1256
+
1257
+ // First time around we should compile both foo and bar
1258
+ p. cargo ( "generate-lockfile" )
1259
+ . with_stderr ( & format ! (
1260
+ "[UPDATING] git repository `{}`\n " ,
1261
+ git_project. url( ) ,
1262
+ ) )
1263
+ . run ( ) ;
1264
+ // Modify a file manually, shouldn't trigger a recompile
1265
+ git_project. change_file ( "src/lib.rs" , r#"pub fn bar() { println!("hello!"); }"# ) ;
1266
+ // Commit the changes and make sure we don't trigger a recompile because the
1267
+ // lock file says not to change
1268
+ let repo = git2:: Repository :: open ( & git_project. root ( ) ) . unwrap ( ) ;
1269
+ git:: add ( & repo) ;
1270
+ git:: commit ( & repo) ;
1271
+ p. change_file ( "Cargo.toml" , & workspace_toml. replace ( "2.29.8" , "2.29.81" ) ) ;
1272
+
1273
+ p. cargo ( "update --workspace" )
1274
+ . with_stderr (
1275
+ "\
1276
+ [UPDATING] crate1 v2.29.8 ([CWD]/crate1) -> v2.29.81
1277
+ [UPDATING] crate2 v2.29.8 ([CWD]/crate2) -> v2.29.81" ,
1278
+ )
1279
+ . run ( ) ;
1280
+ }
0 commit comments