@@ -8,7 +8,7 @@ use crate::support::project;
8
8
use crate :: support:: registry:: Package ;
9
9
use crate :: support:: resolver:: {
10
10
assert_contains, assert_same, dep, dep_kind, dep_loc, dep_req, loc_names, names, pkg, pkg_dep,
11
- pkg_id, pkg_loc, registry, registry_strategy, resolve, resolve_and_validated,
11
+ pkg_id, pkg_loc, registry, registry_strategy, remove_dep , resolve, resolve_and_validated,
12
12
resolve_with_config, PrettyPrintRegistry , ToDep , ToPkgId ,
13
13
} ;
14
14
@@ -108,11 +108,53 @@ proptest! {
108
108
}
109
109
}
110
110
111
+ /// NOTE: if you think this test has failed spuriously see the note at the top of this macro.
112
+ #[ test]
113
+ fn removing_a_dep_cant_brake(
114
+ PrettyPrintRegistry ( input) in registry_strategy( 50 , 20 , 60 ) ,
115
+ indexs_to_remove in collection:: vec( ( any:: <prop:: sample:: Index >( ) , any:: <prop:: sample:: Index >( ) ) , ..10 )
116
+ ) {
117
+ let reg = registry( input. clone( ) ) ;
118
+ let mut removed_input = input. clone( ) ;
119
+ for ( summery_idx, dep_idx) in indexs_to_remove {
120
+ if removed_input. len( ) > 0 {
121
+ let summery_idx = summery_idx. index( removed_input. len( ) ) ;
122
+ let deps = removed_input[ summery_idx] . dependencies( ) ;
123
+ if deps. len( ) > 0 {
124
+ let new = remove_dep( & removed_input[ summery_idx] , dep_idx. index( deps. len( ) ) ) ;
125
+ removed_input[ summery_idx] = new;
126
+ }
127
+ }
128
+ }
129
+ let removed_reg = registry( removed_input) ;
130
+ // there is only a small chance that eny one
131
+ // crate will be interesting.
132
+ // So we try some of the most complicated.
133
+ for this in input. iter( ) . rev( ) . take( 10 ) {
134
+ if resolve(
135
+ & pkg_id( "root" ) ,
136
+ vec![ dep_req( & this. name( ) , & format!( "={}" , this. version( ) ) ) ] ,
137
+ & reg,
138
+ ) . is_ok( ) {
139
+ prop_assert!(
140
+ resolve(
141
+ & pkg_id( "root" ) ,
142
+ vec![ dep_req( & this. name( ) , & format!( "={}" , this. version( ) ) ) ] ,
143
+ & removed_reg,
144
+ ) . is_ok( ) ,
145
+ "full index worked for `{} = \" ={}\" ` but removing some deps broke it!" ,
146
+ this. name( ) ,
147
+ this. version( ) ,
148
+ )
149
+ }
150
+ }
151
+ }
152
+
111
153
/// NOTE: if you think this test has failed spuriously see the note at the top of this macro.
112
154
#[ test]
113
155
fn limited_independence_of_irrelevant_alternatives(
114
156
PrettyPrintRegistry ( input) in registry_strategy( 50 , 20 , 60 ) ,
115
- indexs_to_unpublish in collection:: vec( any:: <prop:: sample:: Index >( ) , 10 )
157
+ indexs_to_unpublish in collection:: vec( any:: <prop:: sample:: Index >( ) , .. 10 )
116
158
) {
117
159
let reg = registry( input. clone( ) ) ;
118
160
// there is only a small chance that eny one
0 commit comments