@@ -1128,4 +1128,106 @@ fn path_dep_outside_workspace_is_not_member() {
1128
1128
1129
1129
assert_that ( p. cargo ( "build" ) . cwd ( p. root ( ) . join ( "ws" ) ) ,
1130
1130
execs ( ) . with_status ( 0 ) ) ;
1131
- }
1131
+ }
1132
+
1133
+ #[ test]
1134
+ fn test_in_and_out_of_workspace ( ) {
1135
+ let p = project ( "foo" )
1136
+ . file ( "ws/Cargo.toml" , r#"
1137
+ [project]
1138
+ name = "ws"
1139
+ version = "0.1.0"
1140
+ authors = []
1141
+
1142
+ [dependencies]
1143
+ foo = { path = "../foo" }
1144
+
1145
+ [workspace]
1146
+ members = [ "../bar" ]
1147
+ "# )
1148
+ . file ( "ws/src/lib.rs" , r"extern crate foo; pub fn f() { foo::f() }" )
1149
+ . file ( "foo/Cargo.toml" , r#"
1150
+ [project]
1151
+ name = "foo"
1152
+ version = "0.1.0"
1153
+ authors = []
1154
+
1155
+ [dependencies]
1156
+ bar = { path = "../bar" }
1157
+ "# )
1158
+ . file ( "foo/src/lib.rs" , "extern crate bar; pub fn f() { bar::f() }" )
1159
+ . file ( "bar/Cargo.toml" , r#"
1160
+ [project]
1161
+ workspace = "../ws"
1162
+ name = "bar"
1163
+ version = "0.1.0"
1164
+ authors = []
1165
+ "# )
1166
+ . file ( "bar/src/lib.rs" , "pub fn f() { }" ) ;
1167
+ p. build ( ) ;
1168
+
1169
+ assert_that ( p. cargo ( "build" ) . cwd ( p. root ( ) . join ( "ws" ) ) ,
1170
+ execs ( ) . with_status ( 0 ) ) ;
1171
+
1172
+ assert_that ( & p. root ( ) . join ( "ws/Cargo.lock" ) , existing_file ( ) ) ;
1173
+ assert_that ( & p. root ( ) . join ( "ws/target" ) , existing_dir ( ) ) ;
1174
+ assert_that ( & p. root ( ) . join ( "foo/Cargo.lock" ) , is_not ( existing_file ( ) ) ) ;
1175
+ assert_that ( & p. root ( ) . join ( "foo/target" ) , is_not ( existing_dir ( ) ) ) ;
1176
+ assert_that ( & p. root ( ) . join ( "bar/Cargo.lock" ) , is_not ( existing_file ( ) ) ) ;
1177
+ assert_that ( & p. root ( ) . join ( "bar/target" ) , is_not ( existing_dir ( ) ) ) ;
1178
+
1179
+ assert_that ( p. cargo ( "build" ) . cwd ( p. root ( ) . join ( "foo" ) ) ,
1180
+ execs ( ) . with_status ( 0 ) ) ;
1181
+ assert_that ( & p. root ( ) . join ( "foo/Cargo.lock" ) , existing_file ( ) ) ;
1182
+ assert_that ( & p. root ( ) . join ( "foo/target" ) , existing_dir ( ) ) ;
1183
+ assert_that ( & p. root ( ) . join ( "bar/Cargo.lock" ) , is_not ( existing_file ( ) ) ) ;
1184
+ assert_that ( & p. root ( ) . join ( "bar/target" ) , is_not ( existing_dir ( ) ) ) ;
1185
+ }
1186
+
1187
+ #[ test]
1188
+ fn test_path_dependency_under_member ( ) {
1189
+ let p = project ( "foo" )
1190
+ . file ( "ws/Cargo.toml" , r#"
1191
+ [project]
1192
+ name = "ws"
1193
+ version = "0.1.0"
1194
+ authors = []
1195
+
1196
+ [dependencies]
1197
+ foo = { path = "../foo" }
1198
+
1199
+ "# )
1200
+ . file ( "ws/src/lib.rs" , r"extern crate foo; pub fn f() { foo::f() }" )
1201
+ . file ( "foo/Cargo.toml" , r#"
1202
+ [project]
1203
+ workspace = "../ws"
1204
+ name = "foo"
1205
+ version = "0.1.0"
1206
+ authors = []
1207
+
1208
+ [dependencies]
1209
+ bar = { path = "./bar" }
1210
+ "# )
1211
+ . file ( "foo/src/lib.rs" , "extern crate bar; pub fn f() { bar::f() }" )
1212
+ . file ( "foo/bar/Cargo.toml" , r#"
1213
+ [project]
1214
+ name = "bar"
1215
+ version = "0.1.0"
1216
+ authors = []
1217
+ "# )
1218
+ . file ( "foo/bar/src/lib.rs" , "pub fn f() { }" ) ;
1219
+ p. build ( ) ;
1220
+
1221
+ assert_that ( p. cargo ( "build" ) . cwd ( p. root ( ) . join ( "ws" ) ) ,
1222
+ execs ( ) . with_status ( 0 ) ) ;
1223
+
1224
+ assert_that ( & p. root ( ) . join ( "foo/bar/Cargo.lock" ) , is_not ( existing_file ( ) ) ) ;
1225
+ assert_that ( & p. root ( ) . join ( "foo/bar/target" ) , is_not ( existing_dir ( ) ) ) ;
1226
+
1227
+ assert_that ( p. cargo ( "build" ) . cwd ( p. root ( ) . join ( "foo/bar" ) ) ,
1228
+ execs ( ) . with_status ( 0 ) ) ;
1229
+ // Ideally, `foo/bar` should be a member of the workspace,
1230
+ // because it is hierarchically under the workspace member.
1231
+ assert_that ( & p. root ( ) . join ( "foo/bar/Cargo.lock" ) , existing_file ( ) ) ;
1232
+ assert_that ( & p. root ( ) . join ( "foo/bar/target" ) , existing_dir ( ) ) ;
1233
+ }
0 commit comments