@@ -1047,6 +1047,41 @@ fn resolving_with_constrained_sibling_backtrack_activation() {
10471047 ) ;
10481048}
10491049
1050+ #[ test]
1051+ fn resolving_with_public_constrained_sibling ( ) {
1052+ // It makes sense to resolve most-constrained deps first, but
1053+ // with that logic the backtrack traps here come between the two
1054+ // attempted resolutions of 'constrained'. When backtracking,
1055+ // cargo should skip past them and resume resolution once the
1056+ // number of activations for 'constrained' changes.
1057+ let mut reglist = vec ! [
1058+ pkg!( ( "foo" , "1.0.0" ) => [ dep_req( "bar" , "=1.0.0" ) ,
1059+ dep_req( "backtrack_trap1" , "1.0" ) ,
1060+ dep_req( "backtrack_trap2" , "1.0" ) ,
1061+ dep_req( "constrained" , "<=60" ) ] ) ,
1062+ pkg!( ( "bar" , "1.0.0" ) => [ dep_req_kind( "constrained" , ">=60" , Kind :: Normal , true ) ] ) ,
1063+ ] ;
1064+ // Bump these to make the test harder, but you'll also need to
1065+ // change the version constraints on `constrained` above. To correctly
1066+ // exercise Cargo, the relationship between the values is:
1067+ // NUM_CONSTRAINED - vsn < NUM_TRAPS < vsn
1068+ // to make sure the traps are resolved between `constrained`.
1069+ const NUM_TRAPS : usize = 45 ; // min 1
1070+ const NUM_CONSTRAINED : usize = 100 ; // min 1
1071+ for i in 0 ..NUM_TRAPS {
1072+ let vsn = format ! ( "1.0.{}" , i) ;
1073+ reglist. push ( pkg ! ( ( "backtrack_trap1" , vsn. clone( ) ) ) ) ;
1074+ reglist. push ( pkg ! ( ( "backtrack_trap2" , vsn. clone( ) ) ) ) ;
1075+ }
1076+ for i in 0 ..NUM_CONSTRAINED {
1077+ let vsn = format ! ( "{}.0.0" , i) ;
1078+ reglist. push ( pkg ! ( ( "constrained" , vsn. clone( ) ) ) ) ;
1079+ }
1080+ let reg = registry ( reglist) ;
1081+
1082+ let _ = resolve_and_validated ( vec ! [ dep_req( "foo" , "1" ) ] , & reg, None ) ;
1083+ }
1084+
10501085#[ test]
10511086fn resolving_with_constrained_sibling_transitive_dep_effects ( ) {
10521087 // When backtracking due to a failed dependency, if Cargo is
0 commit comments