@@ -1562,3 +1562,37 @@ package `A v0.0.0 (registry `https://example.com/`)`
1562
1562
... which satisfies dependency `C = \" *\" ` of package `A v0.0.0 (registry `https://example.com/`)`\
1563
1563
", error. to_string( ) ) ;
1564
1564
}
1565
+
1566
+ #[ test]
1567
+ fn shortest_path_in_error_message ( ) {
1568
+ let input = vec ! [
1569
+ pkg!( ( "F" , "0.1.2" ) ) ,
1570
+ pkg!( ( "F" , "0.1.1" ) => [ dep( "bad" ) , ] ) ,
1571
+ pkg!( ( "F" , "0.1.0" ) => [ dep( "bad" ) , ] ) ,
1572
+ pkg!( "E" => [ dep_req( "F" , "^0.1.2" ) , ] ) ,
1573
+ pkg!( "D" => [ dep_req( "F" , "^0.1.2" ) , ] ) ,
1574
+ pkg!( "C" => [ dep( "D" ) , ] ) ,
1575
+ pkg!( "A" => [ dep( "C" ) , dep( "E" ) , dep_req( "F" , "<=0.1.1" ) , ] ) ,
1576
+ ] ;
1577
+ let error = resolve ( vec ! [ dep( "A" ) ] , & registry ( input) ) . unwrap_err ( ) ;
1578
+ println ! ( "{}" , error) ;
1579
+ assert_eq ! (
1580
+ "\
1581
+ failed to select a version for `F`.
1582
+ ... required by package `A v1.0.0 (registry `https://example.com/`)`
1583
+ ... which satisfies dependency `A = \" *\" ` of package `root v1.0.0 (registry `https://example.com/`)`
1584
+ versions that meet the requirements `<=0.1.1` are: 0.1.1, 0.1.0
1585
+
1586
+ all possible versions conflict with previously selected packages.
1587
+
1588
+ previously selected package `F v0.1.2 (registry `https://example.com/`)`
1589
+ ... which satisfies dependency `F = \" ^0.1.2\" ` of package `D v1.0.0 (registry `https://example.com/`)`
1590
+ ... which satisfies dependency `D = \" *\" ` of package `C v1.0.0 (registry `https://example.com/`)`
1591
+ ... which satisfies dependency `C = \" *\" ` of package `A v1.0.0 (registry `https://example.com/`)`
1592
+ ... which satisfies dependency `A = \" *\" ` of package `root v1.0.0 (registry `https://example.com/`)`
1593
+
1594
+ failed to select a version for `F` which could resolve this conflict\
1595
+ ",
1596
+ error. to_string( )
1597
+ ) ;
1598
+ }
0 commit comments