@@ -1431,3 +1431,50 @@ Caused by:
1431
1431
let lockfile = p. read_lockfile ( ) ;
1432
1432
assert ! ( lockfile. contains( "\n name = \" bar\" \n version = \" 0.1.1\" " ) ) ;
1433
1433
}
1434
+
1435
+ #[ cargo_test]
1436
+ fn precise_yanked_multiple_presence ( ) {
1437
+ Package :: new ( "bar" , "0.1.0" ) . publish ( ) ;
1438
+ Package :: new ( "bar" , "0.1.1" ) . yanked ( true ) . publish ( ) ;
1439
+ let p = project ( )
1440
+ . file (
1441
+ "Cargo.toml" ,
1442
+ r#"
1443
+ [package]
1444
+ name = "foo"
1445
+
1446
+ [dependencies]
1447
+ bar = "0.1"
1448
+ baz = { package = "bar", version = "0.1" }
1449
+ "# ,
1450
+ )
1451
+ . file ( "src/lib.rs" , "" )
1452
+ . build ( ) ;
1453
+
1454
+ p. cargo ( "generate-lockfile" ) . run ( ) ;
1455
+
1456
+ // Use non-yanked version.
1457
+ let lockfile = p. read_lockfile ( ) ;
1458
+ assert ! ( lockfile. contains( "\n name = \" bar\" \n version = \" 0.1.0\" " ) ) ;
1459
+
1460
+ p. cargo ( "update --precise 0.1.1 bar" )
1461
+ . masquerade_as_nightly_cargo ( & [ "--precise <yanked-version>" ] )
1462
+ . arg ( "-Zunstable-options" )
1463
+ . with_stderr (
1464
+ "\
1465
+ [UPDATING] `dummy-registry` index
1466
+ [WARNING] yanked package `bar@0.1.1` is selected by the `--precise` flag from registry `dummy-registry`
1467
+ [NOTE] it is not recommended to depend on a yanked version
1468
+ [NOTE] if possible, try other SemVer-compatbile versions
1469
+ [WARNING] yanked package `bar@0.1.1` is selected by the `--precise` flag from registry `dummy-registry`
1470
+ [NOTE] it is not recommended to depend on a yanked version
1471
+ [NOTE] if possible, try other SemVer-compatbile versions
1472
+ [UPDATING] bar v0.1.0 -> v0.1.1
1473
+ " ,
1474
+ )
1475
+ . run ( ) ;
1476
+
1477
+ // Use yanked version.
1478
+ let lockfile = p. read_lockfile ( ) ;
1479
+ assert ! ( lockfile. contains( "\n name = \" bar\" \n version = \" 0.1.1\" " ) ) ;
1480
+ }
0 commit comments