@@ -2398,7 +2398,7 @@ fn http_api_not_noop() {
2398
2398
}
2399
2399
2400
2400
#[ cargo_test]
2401
- fn wait_for_publish ( ) {
2401
+ fn wait_for_first_publish ( ) {
2402
2402
// Counter for number of tries before the package is "published"
2403
2403
let arc: Arc < Mutex < u32 > > = Arc :: new ( Mutex :: new ( 0 ) ) ;
2404
2404
let arc2 = arc. clone ( ) ;
@@ -2483,7 +2483,7 @@ See [..]
2483
2483
/// the responder twice per cargo invocation. If that ever gets changed
2484
2484
/// this test will need to be changed accordingly.
2485
2485
#[ cargo_test]
2486
- fn wait_for_publish_underscore ( ) {
2486
+ fn wait_for_first_publish_underscore ( ) {
2487
2487
// Counter for number of tries before the package is "published"
2488
2488
let arc: Arc < Mutex < u32 > > = Arc :: new ( Mutex :: new ( 0 ) ) ;
2489
2489
let arc2 = arc. clone ( ) ;
@@ -2565,6 +2565,93 @@ See [..]
2565
2565
. run ( ) ;
2566
2566
}
2567
2567
2568
+ #[ cargo_test]
2569
+ fn wait_for_subsequent_publish ( ) {
2570
+ // Counter for number of tries before the package is "published"
2571
+ let arc: Arc < Mutex < u32 > > = Arc :: new ( Mutex :: new ( 0 ) ) ;
2572
+ let arc2 = arc. clone ( ) ;
2573
+
2574
+ // Registry returns an invalid response.
2575
+ let registry = registry:: RegistryBuilder :: new ( )
2576
+ . http_index ( )
2577
+ . http_api ( )
2578
+ . add_responder ( "/index/de/la/delay" , move |req, server| {
2579
+ let mut lock = arc. lock ( ) . unwrap ( ) ;
2580
+ * lock += 1 ;
2581
+ // if the package name contains _ or -
2582
+ if * lock <= 1 {
2583
+ server. not_found ( req)
2584
+ } else {
2585
+ server. index ( req)
2586
+ }
2587
+ } )
2588
+ . build ( ) ;
2589
+
2590
+ // Publish an earlier version
2591
+ Package :: new ( "delay" , "0.0.1" )
2592
+ . file ( "src/lib.rs" , "" )
2593
+ . publish ( ) ;
2594
+
2595
+ let p = project ( )
2596
+ . file (
2597
+ "Cargo.toml" ,
2598
+ r#"
2599
+ [package]
2600
+ name = "delay"
2601
+ version = "0.0.2"
2602
+ authors = []
2603
+ license = "MIT"
2604
+ description = "foo"
2605
+
2606
+ "# ,
2607
+ )
2608
+ . file ( "src/lib.rs" , "" )
2609
+ . build ( ) ;
2610
+
2611
+ p. cargo ( "publish --no-verify -Z sparse-registry" )
2612
+ . masquerade_as_nightly_cargo ( & [ "sparse-registry" ] )
2613
+ . replace_crates_io ( registry. index_url ( ) )
2614
+ . with_status ( 0 )
2615
+ . with_stderr (
2616
+ "\
2617
+ [UPDATING] crates.io index
2618
+ [WARNING] manifest has no documentation, [..]
2619
+ See [..]
2620
+ [PACKAGING] delay v0.0.2 ([CWD])
2621
+ [PACKAGED] [..] files, [..] ([..] compressed)
2622
+ [UPLOADING] delay v0.0.2 ([CWD])
2623
+ [UPDATING] crates.io index
2624
+ [WAITING] on `delay` to propagate to crates.io index (ctrl-c to wait asynchronously)
2625
+ " ,
2626
+ )
2627
+ . run ( ) ;
2628
+
2629
+ // Verify the responder has been pinged
2630
+ let lock = arc2. lock ( ) . unwrap ( ) ;
2631
+ assert_eq ! ( * lock, 2 ) ;
2632
+ drop ( lock) ;
2633
+
2634
+ let p = project ( )
2635
+ . file (
2636
+ "Cargo.toml" ,
2637
+ r#"
2638
+ [package]
2639
+ name = "foo"
2640
+ version = "0.0.1"
2641
+ authors = []
2642
+ [dependencies]
2643
+ delay = "0.0.2"
2644
+ "# ,
2645
+ )
2646
+ . file ( "src/main.rs" , "fn main() {}" )
2647
+ . build ( ) ;
2648
+
2649
+ p. cargo ( "build -Z sparse-registry" )
2650
+ . masquerade_as_nightly_cargo ( & [ "sparse-registry" ] )
2651
+ . with_status ( 0 )
2652
+ . run ( ) ;
2653
+ }
2654
+
2568
2655
#[ cargo_test]
2569
2656
fn skip_wait_for_publish ( ) {
2570
2657
// Intentionally using local registry so the crate never makes it to the index
0 commit comments