@@ -2547,6 +2547,97 @@ See [..]
2547
2547
. run ( ) ;
2548
2548
}
2549
2549
2550
+ #[ cargo_test]
2551
+ fn wait_for_subsequent_publish ( ) {
2552
+ // Counter for number of tries before the package is "published"
2553
+ let arc: Arc < Mutex < u32 > > = Arc :: new ( Mutex :: new ( 0 ) ) ;
2554
+ let arc2 = arc. clone ( ) ;
2555
+ let publish_req = Arc :: new ( Mutex :: new ( None ) ) ;
2556
+ let publish_req2 = publish_req. clone ( ) ;
2557
+
2558
+ let registry = registry:: RegistryBuilder :: new ( )
2559
+ . http_index ( )
2560
+ . http_api ( )
2561
+ . add_responder ( "/api/v1/crates/new" , move |req, server| {
2562
+ // Capture the publish request, but defer publishing
2563
+ * publish_req. lock ( ) . unwrap ( ) = Some ( req. clone ( ) ) ;
2564
+ server. ok ( req)
2565
+ } )
2566
+ . add_responder ( "/index/de/la/delay" , move |req, server| {
2567
+ let mut lock = arc. lock ( ) . unwrap ( ) ;
2568
+ * lock += 1 ;
2569
+ if * lock == 3 {
2570
+ // Run the publish on the 3rd attempt
2571
+ server. publish ( & publish_req2. lock ( ) . unwrap ( ) . as_ref ( ) . unwrap ( ) ) ;
2572
+ }
2573
+ server. index ( req)
2574
+ } )
2575
+ . build ( ) ;
2576
+
2577
+ // Publish an earlier version
2578
+ Package :: new ( "delay" , "0.0.1" )
2579
+ . file ( "src/lib.rs" , "" )
2580
+ . publish ( ) ;
2581
+
2582
+ let p = project ( )
2583
+ . file (
2584
+ "Cargo.toml" ,
2585
+ r#"
2586
+ [package]
2587
+ name = "delay"
2588
+ version = "0.0.2"
2589
+ authors = []
2590
+ license = "MIT"
2591
+ description = "foo"
2592
+
2593
+ "# ,
2594
+ )
2595
+ . file ( "src/lib.rs" , "" )
2596
+ . build ( ) ;
2597
+
2598
+ p. cargo ( "publish --no-verify -Z sparse-registry" )
2599
+ . masquerade_as_nightly_cargo ( & [ "sparse-registry" ] )
2600
+ . replace_crates_io ( registry. index_url ( ) )
2601
+ . with_status ( 0 )
2602
+ . with_stderr (
2603
+ "\
2604
+ [UPDATING] crates.io index
2605
+ [WARNING] manifest has no documentation, [..]
2606
+ See [..]
2607
+ [PACKAGING] delay v0.0.2 ([CWD])
2608
+ [UPLOADING] delay v0.0.2 ([CWD])
2609
+ [UPDATING] crates.io index
2610
+ [WAITING] on `delay` to propagate to crates.io index (ctrl-c to wait asynchronously)
2611
+ " ,
2612
+ )
2613
+ . run ( ) ;
2614
+
2615
+ // Verify the responder has been pinged
2616
+ let lock = arc2. lock ( ) . unwrap ( ) ;
2617
+ assert_eq ! ( * lock, 3 ) ;
2618
+ drop ( lock) ;
2619
+
2620
+ let p = project ( )
2621
+ . file (
2622
+ "Cargo.toml" ,
2623
+ r#"
2624
+ [package]
2625
+ name = "foo"
2626
+ version = "0.0.1"
2627
+ authors = []
2628
+ [dependencies]
2629
+ delay = "0.0.2"
2630
+ "# ,
2631
+ )
2632
+ . file ( "src/main.rs" , "fn main() {}" )
2633
+ . build ( ) ;
2634
+
2635
+ p. cargo ( "build -Z sparse-registry" )
2636
+ . masquerade_as_nightly_cargo ( & [ "sparse-registry" ] )
2637
+ . with_status ( 0 )
2638
+ . run ( ) ;
2639
+ }
2640
+
2550
2641
#[ cargo_test]
2551
2642
fn skip_wait_for_publish ( ) {
2552
2643
// Intentionally using local registry so the crate never makes it to the index
0 commit comments