@@ -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 ( ) ;
@@ -2419,12 +2419,6 @@ fn wait_for_publish() {
2419
2419
} )
2420
2420
. build ( ) ;
2421
2421
2422
- // The sparse-registry test server does not know how to publish on its own.
2423
- // So let us call publish for it.
2424
- Package :: new ( "delay" , "0.0.1" )
2425
- . file ( "src/lib.rs" , "" )
2426
- . publish ( ) ;
2427
-
2428
2422
let p = project ( )
2429
2423
. file (
2430
2424
"Cargo.toml" ,
@@ -2489,7 +2483,7 @@ See [..]
2489
2483
/// the responder twice per cargo invocation. If that ever gets changed
2490
2484
/// this test will need to be changed accordingly.
2491
2485
#[ cargo_test]
2492
- fn wait_for_publish_underscore ( ) {
2486
+ fn wait_for_first_publish_underscore ( ) {
2493
2487
// Counter for number of tries before the package is "published"
2494
2488
let arc: Arc < Mutex < u32 > > = Arc :: new ( Mutex :: new ( 0 ) ) ;
2495
2489
let arc2 = arc. clone ( ) ;
@@ -2510,12 +2504,6 @@ fn wait_for_publish_underscore() {
2510
2504
} )
2511
2505
. build ( ) ;
2512
2506
2513
- // The sparse-registry test server does not know how to publish on its own.
2514
- // So let us call publish for it.
2515
- Package :: new ( "delay_with_underscore" , "0.0.1" )
2516
- . file ( "src/lib.rs" , "" )
2517
- . publish ( ) ;
2518
-
2519
2507
let p = project ( )
2520
2508
. file (
2521
2509
"Cargo.toml" ,
@@ -2577,6 +2565,93 @@ See [..]
2577
2565
. run ( ) ;
2578
2566
}
2579
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 <= 2 {
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, 3 ) ;
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
+
2580
2655
#[ cargo_test]
2581
2656
fn skip_wait_for_publish ( ) {
2582
2657
// Intentionally using local registry so the crate never makes it to the index
0 commit comments