@@ -6,8 +6,8 @@ use cargo::util::Config;
66use cargo_util:: is_ci;
77
88use resolver_tests:: {
9- assert_contains, assert_same, dep, dep_kind, dep_loc, dep_req, dep_req_kind , loc_names, names,
10- pkg , pkg_id , pkg_loc, registry, registry_strategy, remove_dep, resolve, resolve_and_validated,
9+ assert_contains, assert_same, dep, dep_kind, dep_loc, dep_req, loc_names, names, pkg , pkg_id ,
10+ pkg_loc, registry, registry_strategy, remove_dep, resolve, resolve_and_validated,
1111 resolve_with_config, PrettyPrintRegistry , SatResolve , ToDep , ToPkgId ,
1212} ;
1313
@@ -287,192 +287,6 @@ proptest! {
287287 }
288288}
289289
290- #[ test]
291- #[ should_panic( expected = "pub dep" ) ] // The error handling is not yet implemented.
292- fn pub_fail ( ) {
293- let input = vec ! [
294- pkg!( ( "a" , "0.0.4" ) ) ,
295- pkg!( ( "a" , "0.0.5" ) ) ,
296- pkg!( ( "e" , "0.0.6" ) => [ dep_req_kind( "a" , "<= 0.0.4" , DepKind :: Normal , true ) , ] ) ,
297- pkg!( ( "kB" , "0.0.3" ) => [ dep_req( "a" , ">= 0.0.5" ) , dep( "e" ) , ] ) ,
298- ] ;
299- let reg = registry ( input) ;
300- assert ! ( resolve_and_validated( vec![ dep( "kB" ) ] , & reg, None ) . is_err( ) ) ;
301- }
302-
303- #[ test]
304- fn basic_public_dependency ( ) {
305- let reg = registry ( vec ! [
306- pkg!( ( "A" , "0.1.0" ) ) ,
307- pkg!( ( "A" , "0.2.0" ) ) ,
308- pkg!( "B" => [ dep_req_kind( "A" , "0.1" , DepKind :: Normal , true ) ] ) ,
309- pkg!( "C" => [ dep( "A" ) , dep( "B" ) ] ) ,
310- ] ) ;
311-
312- let res = resolve_and_validated ( vec ! [ dep( "C" ) ] , & reg, None ) . unwrap ( ) ;
313- assert_same (
314- & res,
315- & names ( & [
316- ( "root" , "1.0.0" ) ,
317- ( "C" , "1.0.0" ) ,
318- ( "B" , "1.0.0" ) ,
319- ( "A" , "0.1.0" ) ,
320- ] ) ,
321- ) ;
322- }
323-
324- #[ test]
325- fn public_dependency_filling_in ( ) {
326- // The resolver has an optimization where if a candidate to resolve a dependency
327- // has already bean activated then we skip looking at the candidates dependencies.
328- // However, we have to be careful as the new path may make pub dependencies invalid.
329-
330- // Triggering this case requires dependencies to be resolved in a specific order.
331- // Fuzzing found this unintuitive case, that triggers this unfortunate order of operations:
332- // 1. `d`'s dep on `c` is resolved
333- // 2. `d`'s dep on `a` is resolved with `0.1.1`
334- // 3. `c`'s dep on `b` is resolved with `0.0.2`
335- // 4. `b`'s dep on `a` is resolved with `0.0.6` no pub dev conflict as `b` is private to `c`
336- // 5. `d`'s dep on `b` is resolved with `0.0.2` triggering the optimization.
337- // Do we notice that `d` has a pub dep conflict on `a`? Lets try it and see.
338- let reg = registry ( vec ! [
339- pkg!( ( "a" , "0.0.6" ) ) ,
340- pkg!( ( "a" , "0.1.1" ) ) ,
341- pkg!( ( "b" , "0.0.0" ) => [ dep( "bad" ) ] ) ,
342- pkg!( ( "b" , "0.0.1" ) => [ dep( "bad" ) ] ) ,
343- pkg!( ( "b" , "0.0.2" ) => [ dep_req_kind( "a" , "=0.0.6" , DepKind :: Normal , true ) ] ) ,
344- pkg!( "c" => [ dep_req( "b" , ">=0.0.1" ) ] ) ,
345- pkg!( "d" => [ dep( "c" ) , dep( "a" ) , dep( "b" ) ] ) ,
346- ] ) ;
347-
348- let res = resolve_and_validated ( vec ! [ dep( "d" ) ] , & reg, None ) . unwrap ( ) ;
349- assert_same (
350- & res,
351- & names ( & [
352- ( "root" , "1.0.0" ) ,
353- ( "d" , "1.0.0" ) ,
354- ( "c" , "1.0.0" ) ,
355- ( "b" , "0.0.2" ) ,
356- ( "a" , "0.0.6" ) ,
357- ] ) ,
358- ) ;
359- }
360-
361- #[ test]
362- fn public_dependency_filling_in_and_update ( ) {
363- // The resolver has an optimization where if a candidate to resolve a dependency
364- // has already bean activated then we skip looking at the candidates dependencies.
365- // However, we have to be careful as the new path may make pub dependencies invalid.
366-
367- // Triggering this case requires dependencies to be resolved in a specific order.
368- // Fuzzing found this unintuitive case, that triggers this unfortunate order of operations:
369- // 1. `D`'s dep on `B` is resolved
370- // 2. `D`'s dep on `C` is resolved
371- // 3. `B`'s dep on `A` is resolved with `0.0.0`
372- // 4. `C`'s dep on `B` triggering the optimization.
373- // So did we add `A 0.0.0` to the deps `C` can see?
374- // Or are we going to resolve `C`'s dep on `A` with `0.0.2`?
375- // Lets try it and see.
376- let reg = registry ( vec ! [
377- pkg!( ( "A" , "0.0.0" ) ) ,
378- pkg!( ( "A" , "0.0.2" ) ) ,
379- pkg!( "B" => [ dep_req_kind( "A" , "=0.0.0" , DepKind :: Normal , true ) , ] ) ,
380- pkg!( "C" => [ dep( "A" ) , dep( "B" ) ] ) ,
381- pkg!( "D" => [ dep( "B" ) , dep( "C" ) ] ) ,
382- ] ) ;
383- let res = resolve_and_validated ( vec ! [ dep( "D" ) ] , & reg, None ) . unwrap ( ) ;
384- assert_same (
385- & res,
386- & names ( & [
387- ( "root" , "1.0.0" ) ,
388- ( "D" , "1.0.0" ) ,
389- ( "C" , "1.0.0" ) ,
390- ( "B" , "1.0.0" ) ,
391- ( "A" , "0.0.0" ) ,
392- ] ) ,
393- ) ;
394- }
395-
396- #[ test]
397- fn public_dependency_skipping ( ) {
398- // When backtracking due to a failed dependency, if Cargo is
399- // trying to be clever and skip irrelevant dependencies, care must
400- // the effects of pub dep must be accounted for.
401- let input = vec ! [
402- pkg!( ( "a" , "0.2.0" ) ) ,
403- pkg!( ( "a" , "2.0.0" ) ) ,
404- pkg!( ( "b" , "0.0.0" ) => [ dep( "bad" ) ] ) ,
405- pkg!( ( "b" , "0.2.1" ) => [ dep_req_kind( "a" , "0.2.0" , DepKind :: Normal , true ) ] ) ,
406- pkg!( "c" => [ dep( "a" ) , dep( "b" ) ] ) ,
407- ] ;
408- let reg = registry ( input) ;
409-
410- resolve_and_validated ( vec ! [ dep( "c" ) ] , & reg, None ) . unwrap ( ) ;
411- }
412-
413- #[ test]
414- fn public_dependency_skipping_in_backtracking ( ) {
415- // When backtracking due to a failed dependency, if Cargo is
416- // trying to be clever and skip irrelevant dependencies, care must
417- // the effects of pub dep must be accounted for.
418- let input = vec ! [
419- pkg!( ( "A" , "0.0.0" ) => [ dep( "bad" ) ] ) ,
420- pkg!( ( "A" , "0.0.1" ) => [ dep( "bad" ) ] ) ,
421- pkg!( ( "A" , "0.0.2" ) => [ dep( "bad" ) ] ) ,
422- pkg!( ( "A" , "0.0.3" ) => [ dep( "bad" ) ] ) ,
423- pkg!( ( "A" , "0.0.4" ) ) ,
424- pkg!( ( "A" , "0.0.5" ) ) ,
425- pkg!( "B" => [ dep_req_kind( "A" , ">= 0.0.3" , DepKind :: Normal , true ) ] ) ,
426- pkg!( "C" => [ dep_req( "A" , "<= 0.0.4" ) , dep( "B" ) ] ) ,
427- ] ;
428- let reg = registry ( input) ;
429-
430- resolve_and_validated ( vec ! [ dep( "C" ) ] , & reg, None ) . unwrap ( ) ;
431- }
432-
433- #[ test]
434- fn public_sat_topological_order ( ) {
435- let input = vec ! [
436- pkg!( ( "a" , "0.0.1" ) ) ,
437- pkg!( ( "a" , "0.0.0" ) ) ,
438- pkg!( ( "b" , "0.0.1" ) => [ dep_req_kind( "a" , "= 0.0.1" , DepKind :: Normal , true ) , ] ) ,
439- pkg!( ( "b" , "0.0.0" ) => [ dep( "bad" ) , ] ) ,
440- pkg!( "A" => [ dep_req( "a" , "= 0.0.0" ) , dep_req_kind( "b" , "*" , DepKind :: Normal , true ) ] ) ,
441- ] ;
442-
443- let reg = registry ( input) ;
444- assert ! ( resolve_and_validated( vec![ dep( "A" ) ] , & reg, None ) . is_err( ) ) ;
445- }
446-
447- #[ test]
448- fn public_sat_unused_makes_things_pub ( ) {
449- let input = vec ! [
450- pkg!( ( "a" , "0.0.1" ) ) ,
451- pkg!( ( "a" , "0.0.0" ) ) ,
452- pkg!( ( "b" , "8.0.1" ) => [ dep_req_kind( "a" , "= 0.0.1" , DepKind :: Normal , true ) , ] ) ,
453- pkg!( ( "b" , "8.0.0" ) => [ dep_req( "a" , "= 0.0.1" ) , ] ) ,
454- pkg!( "c" => [ dep_req( "b" , "= 8.0.0" ) , dep_req( "a" , "= 0.0.0" ) , ] ) ,
455- ] ;
456- let reg = registry ( input) ;
457-
458- resolve_and_validated ( vec ! [ dep( "c" ) ] , & reg, None ) . unwrap ( ) ;
459- }
460-
461- #[ test]
462- fn public_sat_unused_makes_things_pub_2 ( ) {
463- let input = vec ! [
464- pkg!( ( "c" , "0.0.2" ) ) ,
465- pkg!( ( "c" , "0.0.1" ) ) ,
466- pkg!( ( "a-sys" , "0.0.2" ) ) ,
467- pkg!( ( "a-sys" , "0.0.1" ) => [ dep_req_kind( "c" , "= 0.0.1" , DepKind :: Normal , true ) , ] ) ,
468- pkg!( "P" => [ dep_req_kind( "a-sys" , "*" , DepKind :: Normal , true ) , dep_req( "c" , "= 0.0.1" ) , ] ) ,
469- pkg!( "A" => [ dep( "P" ) , dep_req( "c" , "= 0.0.2" ) , ] ) ,
470- ] ;
471- let reg = registry ( input) ;
472-
473- resolve_and_validated ( vec ! [ dep( "A" ) ] , & reg, None ) . unwrap ( ) ;
474- }
475-
476290#[ test]
477291#[ should_panic( expected = "assertion failed: !name.is_empty()" ) ]
478292fn test_dependency_with_empty_name ( ) {
@@ -1115,41 +929,6 @@ fn resolving_with_constrained_sibling_backtrack_activation() {
1115929 ) ;
1116930}
1117931
1118- #[ test]
1119- fn resolving_with_public_constrained_sibling ( ) {
1120- // It makes sense to resolve most-constrained deps first, but
1121- // with that logic the backtrack traps here come between the two
1122- // attempted resolutions of 'constrained'. When backtracking,
1123- // cargo should skip past them and resume resolution once the
1124- // number of activations for 'constrained' changes.
1125- let mut reglist = vec ! [
1126- pkg!( ( "foo" , "1.0.0" ) => [ dep_req( "bar" , "=1.0.0" ) ,
1127- dep_req( "backtrack_trap1" , "1.0" ) ,
1128- dep_req( "backtrack_trap2" , "1.0" ) ,
1129- dep_req( "constrained" , "<=60" ) ] ) ,
1130- pkg!( ( "bar" , "1.0.0" ) => [ dep_req_kind( "constrained" , ">=60" , DepKind :: Normal , true ) ] ) ,
1131- ] ;
1132- // Bump these to make the test harder, but you'll also need to
1133- // change the version constraints on `constrained` above. To correctly
1134- // exercise Cargo, the relationship between the values is:
1135- // NUM_CONSTRAINED - vsn < NUM_TRAPS < vsn
1136- // to make sure the traps are resolved between `constrained`.
1137- const NUM_TRAPS : usize = 45 ; // min 1
1138- const NUM_CONSTRAINED : usize = 100 ; // min 1
1139- for i in 0 ..NUM_TRAPS {
1140- let vsn = format ! ( "1.0.{}" , i) ;
1141- reglist. push ( pkg ! ( ( "backtrack_trap1" , vsn. clone( ) ) ) ) ;
1142- reglist. push ( pkg ! ( ( "backtrack_trap2" , vsn. clone( ) ) ) ) ;
1143- }
1144- for i in 0 ..NUM_CONSTRAINED {
1145- let vsn = format ! ( "{}.0.0" , i) ;
1146- reglist. push ( pkg ! ( ( "constrained" , vsn. clone( ) ) ) ) ;
1147- }
1148- let reg = registry ( reglist) ;
1149-
1150- let _ = resolve_and_validated ( vec ! [ dep_req( "foo" , "1" ) ] , & reg, None ) ;
1151- }
1152-
1153932#[ test]
1154933fn resolving_with_constrained_sibling_transitive_dep_effects ( ) {
1155934 // When backtracking due to a failed dependency, if Cargo is
0 commit comments