@@ -1167,13 +1167,13 @@ fn unknown_registry() {
1167
1167
}
1168
1168
1169
1169
#[ test]
1170
- fn registries_index_relative_path ( ) {
1170
+ fn registries_index_relative_url ( ) {
1171
1171
let config = paths:: root ( ) . join ( ".cargo/config" ) ;
1172
1172
fs:: create_dir_all ( config. parent ( ) . unwrap ( ) ) . unwrap ( ) ;
1173
1173
File :: create ( & config) . unwrap ( )
1174
1174
. write_all ( br#"
1175
1175
[registries.relative]
1176
- index = "alternative-registry"
1176
+ index = "file: alternative-registry"
1177
1177
"# ) . unwrap ( ) ;
1178
1178
1179
1179
registry:: init ( ) ;
@@ -1215,13 +1215,13 @@ fn registries_index_relative_path() {
1215
1215
}
1216
1216
1217
1217
#[ test]
1218
- fn registry_index_relative_path ( ) {
1218
+ fn registry_index_relative_url ( ) {
1219
1219
let config = paths:: root ( ) . join ( ".cargo/config" ) ;
1220
1220
fs:: create_dir_all ( config. parent ( ) . unwrap ( ) ) . unwrap ( ) ;
1221
1221
File :: create ( & config) . unwrap ( )
1222
1222
. write_all ( br#"
1223
1223
[registry]
1224
- index = "alternative-registry"
1224
+ index = "file: alternative-registry"
1225
1225
"# ) . unwrap ( ) ;
1226
1226
1227
1227
registry:: init ( ) ;
@@ -1263,3 +1263,49 @@ warning: custom registry support via the `registry.index` configuration is being
1263
1263
) )
1264
1264
. run ( ) ;
1265
1265
}
1266
+
1267
+ #[ test]
1268
+ fn registries_index_relative_path_not_allowed ( ) {
1269
+ let config = paths:: root ( ) . join ( ".cargo/config" ) ;
1270
+ fs:: create_dir_all ( config. parent ( ) . unwrap ( ) ) . unwrap ( ) ;
1271
+ File :: create ( & config) . unwrap ( )
1272
+ . write_all ( br#"
1273
+ [registries.relative]
1274
+ index = "alternative-registry"
1275
+ "# ) . unwrap ( ) ;
1276
+
1277
+ registry:: init ( ) ;
1278
+
1279
+ let p = project ( )
1280
+ . file (
1281
+ "Cargo.toml" ,
1282
+ r#"
1283
+ [project]
1284
+ name = "foo"
1285
+ version = "0.0.1"
1286
+ authors = []
1287
+
1288
+ [dependencies.bar]
1289
+ version = "0.0.1"
1290
+ registry = "relative"
1291
+ "# ,
1292
+ )
1293
+ . file ( "src/main.rs" , "fn main() {}" )
1294
+ . build ( ) ;
1295
+
1296
+ Package :: new ( "bar" , "0.0.1" )
1297
+ . alternative ( true )
1298
+ . publish ( ) ;
1299
+
1300
+ p. cargo ( "build" )
1301
+ . with_stderr ( & format ! (
1302
+ "\
1303
+ error: failed to parse manifest at `{root}/foo/Cargo.toml`
1304
+
1305
+ Caused by:
1306
+ invalid url `alternative-registry`: relative URL without a base
1307
+ "
1308
+ , root = paths:: root( ) . to_str( ) . unwrap( ) ) )
1309
+ . with_status ( 101 )
1310
+ . run ( ) ;
1311
+ }
0 commit comments