File tree Expand file tree Collapse file tree 3 files changed +13
-6
lines changed
crates/cargo-test-support/src
src/cargo/sources/registry Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -469,6 +469,7 @@ impl Drop for HttpServerHandle {
469
469
}
470
470
471
471
/// Request to the test http server
472
+ #[ derive( Clone ) ]
472
473
pub struct Request {
473
474
pub url : Url ,
474
475
pub method : String ,
Original file line number Diff line number Diff line change @@ -549,6 +549,7 @@ impl<'cfg> RegistryData for HttpRegistry<'cfg> {
549
549
// All it does is ensure that a subsequent load will double-check files with the
550
550
// server rather than rely on a locally cached copy of the index files.
551
551
debug ! ( "invalidated index cache" ) ;
552
+ self . fresh . clear ( ) ;
552
553
self . requested_update = true ;
553
554
}
554
555
Original file line number Diff line number Diff line change @@ -2570,20 +2570,25 @@ fn wait_for_subsequent_publish() {
2570
2570
// Counter for number of tries before the package is "published"
2571
2571
let arc: Arc < Mutex < u32 > > = Arc :: new ( Mutex :: new ( 0 ) ) ;
2572
2572
let arc2 = arc. clone ( ) ;
2573
+ let publish_req = Arc :: new ( Mutex :: new ( None ) ) ;
2574
+ let publish_req2 = publish_req. clone ( ) ;
2573
2575
2574
- // Registry returns an invalid response.
2575
2576
let registry = registry:: RegistryBuilder :: new ( )
2576
2577
. http_index ( )
2577
2578
. http_api ( )
2579
+ . add_responder ( "/api/v1/crates/new" , move |req, server| {
2580
+ // Capture the publish request, but defer publishing
2581
+ * publish_req. lock ( ) . unwrap ( ) = Some ( req. clone ( ) ) ;
2582
+ server. ok ( req)
2583
+ } )
2578
2584
. add_responder ( "/index/de/la/delay" , move |req, server| {
2579
2585
let mut lock = arc. lock ( ) . unwrap ( ) ;
2580
2586
* lock += 1 ;
2581
- // if the package name contains _ or -
2582
- if * lock <= 2 {
2583
- server. not_found ( req)
2584
- } else {
2585
- server. index ( req)
2587
+ if * lock == 3 {
2588
+ // Run the publish on the 3rd attempt
2589
+ server. publish ( & publish_req2. lock ( ) . unwrap ( ) . as_ref ( ) . unwrap ( ) ) ;
2586
2590
}
2591
+ server. index ( req)
2587
2592
} )
2588
2593
. build ( ) ;
2589
2594
You can’t perform that action at this time.
0 commit comments