@@ -291,7 +291,7 @@ fn new_features() {
291
291
292
292
let toolchains = collect_all_toolchains ( ) ;
293
293
294
- let config_path = paths:: home ( ) . join ( ".cargo/config.toml " ) ;
294
+ let config_path = paths:: home ( ) . join ( ".cargo/config" ) ;
295
295
let lock_path = p. root ( ) . join ( "Cargo.lock" ) ;
296
296
297
297
struct ToolchainBehavior {
@@ -305,6 +305,11 @@ fn new_features() {
305
305
let mut unexpected_results: Vec < Vec < String > > = Vec :: new ( ) ;
306
306
307
307
for ( version, toolchain) in & toolchains {
308
+ if version >= & Version :: new ( 1 , 15 , 0 ) && version < & Version :: new ( 1 , 18 , 0 ) {
309
+ // These versions do not stay within the sandbox, and chokes on
310
+ // Cargo's own `Cargo.toml`.
311
+ continue ;
312
+ }
308
313
let mut tc_result = Vec :: new ( ) ;
309
314
// Write a config appropriate for this version.
310
315
if version < & Version :: new ( 1 , 12 , 0 ) {
@@ -347,7 +352,7 @@ fn new_features() {
347
352
let stdout = std:: str:: from_utf8 ( & output. stdout ) . unwrap ( ) ;
348
353
let version = stdout
349
354
. trim ( )
350
- . rsplitn ( 2 , ':' )
355
+ . rsplitn ( 2 , [ '@' , ':' ] )
351
356
. next ( )
352
357
. expect ( "version after colon" ) ;
353
358
Some ( Version :: parse ( version) . expect ( "parseable version" ) )
@@ -443,7 +448,22 @@ fn new_features() {
443
448
}
444
449
}
445
450
Err ( e) => {
446
- tc_result. push ( format ! ( "unlocked build failed: {}" , e) ) ;
451
+ if version < & Version :: new ( 1 , 49 , 0 ) {
452
+ // Old versions don't like the dep: syntax.
453
+ check_err_contains (
454
+ & mut tc_result,
455
+ e,
456
+ "which is neither a dependency nor another feature" ,
457
+ ) ;
458
+ } else if version >= & Version :: new ( 1 , 49 , 0 ) && version < & Version :: new ( 1 , 51 , 0 ) {
459
+ check_err_contains (
460
+ & mut tc_result,
461
+ e,
462
+ "requires the `-Z namespaced-features` flag" ,
463
+ ) ;
464
+ } else {
465
+ tc_result. push ( format ! ( "unlocked build failed: {}" , e) ) ;
466
+ }
447
467
}
448
468
}
449
469
@@ -469,14 +489,29 @@ fn new_features() {
469
489
check_lock ! ( tc_result, "new-baz-dep" , which, behavior. new_baz_dep, None ) ;
470
490
}
471
491
Err ( e) => {
472
- // When version >= 1.51 and <= 1.59,
473
- // 1.0.1 can't be used without -Znamespaced-features
474
- // It gets filtered out of the index.
475
- check_err_contains (
476
- & mut tc_result,
477
- e,
478
- "candidate versions found which didn't match: 1.0.2, 1.0.0" ,
479
- ) ;
492
+ if version < & Version :: new ( 1 , 49 , 0 ) {
493
+ // Old versions don't like the dep: syntax.
494
+ check_err_contains (
495
+ & mut tc_result,
496
+ e,
497
+ "which is neither a dependency nor another feature" ,
498
+ ) ;
499
+ } else if version >= & Version :: new ( 1 , 49 , 0 ) && version < & Version :: new ( 1 , 51 , 0 ) {
500
+ check_err_contains (
501
+ & mut tc_result,
502
+ e,
503
+ "requires the `-Z namespaced-features` flag" ,
504
+ ) ;
505
+ } else {
506
+ // When version >= 1.51 and <= 1.59,
507
+ // 1.0.1 can't be used without -Znamespaced-features
508
+ // It gets filtered out of the index.
509
+ check_err_contains (
510
+ & mut tc_result,
511
+ e,
512
+ "candidate versions found which didn't match: 1.0.2, 1.0.0" ,
513
+ ) ;
514
+ }
480
515
}
481
516
}
482
517
@@ -503,13 +538,28 @@ fn new_features() {
503
538
}
504
539
}
505
540
Err ( e) => {
506
- // When version >= 1.51 and <= 1.59,
507
- // baz can't lock to 1.0.1, it requires -Znamespaced-features
508
- check_err_contains (
509
- & mut tc_result,
510
- e,
511
- "candidate versions found which didn't match: 1.0.0" ,
512
- ) ;
541
+ if version < & Version :: new ( 1 , 49 , 0 ) {
542
+ // Old versions don't like the dep: syntax.
543
+ check_err_contains (
544
+ & mut tc_result,
545
+ e,
546
+ "which is neither a dependency nor another feature" ,
547
+ ) ;
548
+ } else if version >= & Version :: new ( 1 , 49 , 0 ) && version < & Version :: new ( 1 , 51 , 0 ) {
549
+ check_err_contains (
550
+ & mut tc_result,
551
+ e,
552
+ "requires the `-Z namespaced-features` flag" ,
553
+ ) ;
554
+ } else {
555
+ // When version >= 1.51 and <= 1.59,
556
+ // baz can't lock to 1.0.1, it requires -Znamespaced-features
557
+ check_err_contains (
558
+ & mut tc_result,
559
+ e,
560
+ "candidate versions found which didn't match: 1.0.0" ,
561
+ ) ;
562
+ }
513
563
}
514
564
}
515
565
@@ -545,6 +595,7 @@ fn index_cache_rebuild() {
545
595
// happening, and switching between versions should work correctly
546
596
// (although it will thrash the cash, that's better than not working
547
597
// correctly.
598
+ let registry = registry:: init ( ) ;
548
599
Package :: new ( "baz" , "1.0.0" ) . publish ( ) ;
549
600
Package :: new ( "bar" , "1.0.0" ) . publish ( ) ;
550
601
Package :: new ( "bar" , "1.0.1" )
@@ -565,6 +616,19 @@ fn index_cache_rebuild() {
565
616
"# ,
566
617
)
567
618
. file ( "src/lib.rs" , "" )
619
+ . file (
620
+ ".cargo/config.toml" ,
621
+ & format ! (
622
+ r#"
623
+ [source.crates-io]
624
+ replace-with = 'dummy-registry'
625
+
626
+ [source.dummy-registry]
627
+ registry = '{}'
628
+ "# ,
629
+ registry. index_url( )
630
+ ) ,
631
+ )
568
632
. build ( ) ;
569
633
570
634
// This version of Cargo errors on index entries that have overlapping
0 commit comments