@@ -86,12 +86,20 @@ fn collect_all_toolchains() -> Vec<(Version, String)> {
86
86
. map ( |line| ( rustc_version ( line) , line. to_string ( ) ) )
87
87
. collect ( ) ;
88
88
89
- // Also include *this* cargo.
90
- toolchains. push ( ( rustc_version ( "this" ) , "this" . to_string ( ) ) ) ;
91
89
toolchains. sort_by ( |a, b| a. 0 . cmp ( & b. 0 ) ) ;
92
90
toolchains
93
91
}
94
92
93
+ /// Returns whether the default toolchain is the stable version.
94
+ fn default_toolchain_is_stable ( ) -> bool {
95
+ let default = tc_process ( "rustc" , "this" ) . arg ( "-V" ) . exec_with_output ( ) ;
96
+ let stable = tc_process ( "rustc" , "stable" ) . arg ( "-V" ) . exec_with_output ( ) ;
97
+ match ( default, stable) {
98
+ ( Ok ( d) , Ok ( s) ) => d. stdout == s. stdout ,
99
+ _ => false ,
100
+ }
101
+ }
102
+
95
103
// This is a test for exercising the behavior of older versions of cargo with
96
104
// the new feature syntax.
97
105
//
@@ -411,16 +419,27 @@ fn new_features() {
411
419
p. build_dir ( ) . rm_rf ( ) ;
412
420
match run_cargo ( ) {
413
421
Ok ( behavior) => {
414
- // TODO: Switch to 51 after backport.
415
- if version < & Version :: new ( 1 , 52 , 0 ) && toolchain != "this" {
422
+ if version < & Version :: new ( 1 , 51 , 0 ) {
416
423
check_lock ! ( tc_result, "bar" , which, behavior. bar, "1.0.2" ) ;
417
424
check_lock ! ( tc_result, "baz" , which, behavior. baz, "1.0.1" ) ;
418
425
check_lock ! ( tc_result, "new-baz-dep" , which, behavior. new_baz_dep, None ) ;
419
- } else {
426
+ } else if version >= & Version :: new ( 1 , 51 , 0 ) && version <= & Version :: new ( 1 , 59 , 0 ) {
420
427
check_lock ! ( tc_result, "bar" , which, behavior. bar, "1.0.0" ) ;
421
428
check_lock ! ( tc_result, "baz" , which, behavior. baz, None ) ;
422
429
check_lock ! ( tc_result, "new-baz-dep" , which, behavior. new_baz_dep, None ) ;
423
430
}
431
+ // Starting with 1.60, namespaced-features has been stabilized.
432
+ else {
433
+ check_lock ! ( tc_result, "bar" , which, behavior. bar, "1.0.2" ) ;
434
+ check_lock ! ( tc_result, "baz" , which, behavior. baz, "1.0.1" ) ;
435
+ check_lock ! (
436
+ tc_result,
437
+ "new-baz-dep" ,
438
+ which,
439
+ behavior. new_baz_dep,
440
+ "1.0.0"
441
+ ) ;
442
+ }
424
443
}
425
444
Err ( e) => {
426
445
tc_result. push ( format ! ( "unlocked build failed: {}" , e) ) ;
@@ -449,38 +468,48 @@ fn new_features() {
449
468
check_lock ! ( tc_result, "new-baz-dep" , which, behavior. new_baz_dep, None ) ;
450
469
}
451
470
Err ( e) => {
452
- if toolchain == "this" {
453
- // 1.0.1 can't be used without -Znamespaced-features
454
- // It gets filtered out of the index.
455
- check_err_contains ( & mut tc_result, e,
456
- "error: failed to select a version for the requirement `bar = \" =1.0.1\" `\n \
457
- candidate versions found which didn't match: 1.0.2, 1.0.0"
458
- ) ;
459
- } else {
460
- tc_result. push ( format ! ( "bar 1.0.1 locked build failed: {}" , e) ) ;
461
- }
471
+ // When version >= 1.51 and <= 1.59,
472
+ // 1.0.1 can't be used without -Znamespaced-features
473
+ // It gets filtered out of the index.
474
+ check_err_contains (
475
+ & mut tc_result,
476
+ e,
477
+ "candidate versions found which didn't match: 1.0.2, 1.0.0" ,
478
+ ) ;
462
479
}
463
480
}
464
481
465
482
let which = "locked bar 1.0.2" ;
466
483
lock_bar_to ( version, 102 ) ;
467
484
match run_cargo ( ) {
468
485
Ok ( behavior) => {
469
- check_lock ! ( tc_result, "bar" , which, behavior. bar, "1.0.2" ) ;
470
- check_lock ! ( tc_result, "baz" , which, behavior. baz, "1.0.1" ) ;
471
- check_lock ! ( tc_result, "new-baz-dep" , which, behavior. new_baz_dep, None ) ;
472
- }
473
- Err ( e) => {
474
- if toolchain == "this" {
475
- // baz can't lock to 1.0.1, it requires -Znamespaced-features
476
- check_err_contains ( & mut tc_result, e,
477
- "error: failed to select a version for the requirement `baz = \" =1.0.1\" `\n \
478
- candidate versions found which didn't match: 1.0.0"
486
+ if version <= & Version :: new ( 1 , 59 , 0 ) {
487
+ check_lock ! ( tc_result, "bar" , which, behavior. bar, "1.0.2" ) ;
488
+ check_lock ! ( tc_result, "baz" , which, behavior. baz, "1.0.1" ) ;
489
+ check_lock ! ( tc_result, "new-baz-dep" , which, behavior. new_baz_dep, None ) ;
490
+ }
491
+ // Starting with 1.60, namespaced-features has been stabilized.
492
+ else {
493
+ check_lock ! ( tc_result, "bar" , which, behavior. bar, "1.0.2" ) ;
494
+ check_lock ! ( tc_result, "baz" , which, behavior. baz, "1.0.1" ) ;
495
+ check_lock ! (
496
+ tc_result,
497
+ "new-baz-dep" ,
498
+ which,
499
+ behavior. new_baz_dep,
500
+ "1.0.0"
479
501
) ;
480
- } else {
481
- tc_result. push ( format ! ( "bar 1.0.2 locked build failed: {}" , e) ) ;
482
502
}
483
503
}
504
+ Err ( e) => {
505
+ // When version >= 1.51 and <= 1.59,
506
+ // baz can't lock to 1.0.1, it requires -Znamespaced-features
507
+ check_err_contains (
508
+ & mut tc_result,
509
+ e,
510
+ "candidate versions found which didn't match: 1.0.0" ,
511
+ ) ;
512
+ }
484
513
}
485
514
486
515
unexpected_results. push ( tc_result) ;
@@ -590,6 +619,11 @@ foo v0.1.0 [..]
590
619
#[ cargo_test]
591
620
#[ ignore]
592
621
fn avoids_split_debuginfo_collision ( ) {
622
+ // Test needs two different toolchains.
623
+ // If the default toolchain is stable, then it won't work.
624
+ if default_toolchain_is_stable ( ) {
625
+ return ;
626
+ }
593
627
// Checks for a bug where .o files were being incorrectly shared between
594
628
// different toolchains using incremental and split-debuginfo on macOS.
595
629
let p = project ( )
@@ -637,7 +671,6 @@ fn avoids_split_debuginfo_collision() {
637
671
. cwd ( p. root ( ) )
638
672
. with_stderr (
639
673
"\
640
- [COMPILING] foo v0.1.0 [..]
641
674
[FINISHED] [..]
642
675
" ,
643
676
)
0 commit comments