Skip to content

Commit 188298f

Browse files
committed
Auto merge of #10167 - hi-rustin:rustin-patch-test, r=ehuss
Use 1.51.0 in old cargos test Remove TODO. If the default toolchain is the same as "stable", just skip the `avoids_split_debuginfo_collision` test.
2 parents 5be1b1b + 9d93415 commit 188298f

File tree

1 file changed

+61
-28
lines changed

1 file changed

+61
-28
lines changed

tests/testsuite/old_cargos.rs

Lines changed: 61 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,20 @@ fn collect_all_toolchains() -> Vec<(Version, String)> {
8686
.map(|line| (rustc_version(line), line.to_string()))
8787
.collect();
8888

89-
// Also include *this* cargo.
90-
toolchains.push((rustc_version("this"), "this".to_string()));
9189
toolchains.sort_by(|a, b| a.0.cmp(&b.0));
9290
toolchains
9391
}
9492

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+
95103
// This is a test for exercising the behavior of older versions of cargo with
96104
// the new feature syntax.
97105
//
@@ -411,16 +419,27 @@ fn new_features() {
411419
p.build_dir().rm_rf();
412420
match run_cargo() {
413421
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) {
416423
check_lock!(tc_result, "bar", which, behavior.bar, "1.0.2");
417424
check_lock!(tc_result, "baz", which, behavior.baz, "1.0.1");
418425
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) {
420427
check_lock!(tc_result, "bar", which, behavior.bar, "1.0.0");
421428
check_lock!(tc_result, "baz", which, behavior.baz, None);
422429
check_lock!(tc_result, "new-baz-dep", which, behavior.new_baz_dep, None);
423430
}
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+
}
424443
}
425444
Err(e) => {
426445
tc_result.push(format!("unlocked build failed: {}", e));
@@ -449,38 +468,48 @@ fn new_features() {
449468
check_lock!(tc_result, "new-baz-dep", which, behavior.new_baz_dep, None);
450469
}
451470
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+
);
462479
}
463480
}
464481

465482
let which = "locked bar 1.0.2";
466483
lock_bar_to(version, 102);
467484
match run_cargo() {
468485
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"
479501
);
480-
} else {
481-
tc_result.push(format!("bar 1.0.2 locked build failed: {}", e));
482502
}
483503
}
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+
}
484513
}
485514

486515
unexpected_results.push(tc_result);
@@ -590,6 +619,11 @@ foo v0.1.0 [..]
590619
#[cargo_test]
591620
#[ignore]
592621
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+
}
593627
// Checks for a bug where .o files were being incorrectly shared between
594628
// different toolchains using incremental and split-debuginfo on macOS.
595629
let p = project()
@@ -637,7 +671,6 @@ fn avoids_split_debuginfo_collision() {
637671
.cwd(p.root())
638672
.with_stderr(
639673
"\
640-
[COMPILING] foo v0.1.0 [..]
641674
[FINISHED] [..]
642675
",
643676
)

0 commit comments

Comments
 (0)