Skip to content

Commit

Permalink
Auto merge of #10167 - hi-rustin:rustin-patch-test, r=ehuss
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Feb 27, 2022
2 parents 5be1b1b + 9d93415 commit 188298f
Showing 1 changed file with 61 additions and 28 deletions.
89 changes: 61 additions & 28 deletions tests/testsuite/old_cargos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,20 @@ fn collect_all_toolchains() -> Vec<(Version, String)> {
.map(|line| (rustc_version(line), line.to_string()))
.collect();

// Also include *this* cargo.
toolchains.push((rustc_version("this"), "this".to_string()));
toolchains.sort_by(|a, b| a.0.cmp(&b.0));
toolchains
}

/// Returns whether the default toolchain is the stable version.
fn default_toolchain_is_stable() -> bool {
let default = tc_process("rustc", "this").arg("-V").exec_with_output();
let stable = tc_process("rustc", "stable").arg("-V").exec_with_output();
match (default, stable) {
(Ok(d), Ok(s)) => d.stdout == s.stdout,
_ => false,
}
}

// This is a test for exercising the behavior of older versions of cargo with
// the new feature syntax.
//
Expand Down Expand Up @@ -411,16 +419,27 @@ fn new_features() {
p.build_dir().rm_rf();
match run_cargo() {
Ok(behavior) => {
// TODO: Switch to 51 after backport.
if version < &Version::new(1, 52, 0) && toolchain != "this" {
if version < &Version::new(1, 51, 0) {
check_lock!(tc_result, "bar", which, behavior.bar, "1.0.2");
check_lock!(tc_result, "baz", which, behavior.baz, "1.0.1");
check_lock!(tc_result, "new-baz-dep", which, behavior.new_baz_dep, None);
} else {
} else if version >= &Version::new(1, 51, 0) && version <= &Version::new(1, 59, 0) {
check_lock!(tc_result, "bar", which, behavior.bar, "1.0.0");
check_lock!(tc_result, "baz", which, behavior.baz, None);
check_lock!(tc_result, "new-baz-dep", which, behavior.new_baz_dep, None);
}
// Starting with 1.60, namespaced-features has been stabilized.
else {
check_lock!(tc_result, "bar", which, behavior.bar, "1.0.2");
check_lock!(tc_result, "baz", which, behavior.baz, "1.0.1");
check_lock!(
tc_result,
"new-baz-dep",
which,
behavior.new_baz_dep,
"1.0.0"
);
}
}
Err(e) => {
tc_result.push(format!("unlocked build failed: {}", e));
Expand Down Expand Up @@ -449,38 +468,48 @@ fn new_features() {
check_lock!(tc_result, "new-baz-dep", which, behavior.new_baz_dep, None);
}
Err(e) => {
if toolchain == "this" {
// 1.0.1 can't be used without -Znamespaced-features
// It gets filtered out of the index.
check_err_contains(&mut tc_result, e,
"error: failed to select a version for the requirement `bar = \"=1.0.1\"`\n\
candidate versions found which didn't match: 1.0.2, 1.0.0"
);
} else {
tc_result.push(format!("bar 1.0.1 locked build failed: {}", e));
}
// When version >= 1.51 and <= 1.59,
// 1.0.1 can't be used without -Znamespaced-features
// It gets filtered out of the index.
check_err_contains(
&mut tc_result,
e,
"candidate versions found which didn't match: 1.0.2, 1.0.0",
);
}
}

let which = "locked bar 1.0.2";
lock_bar_to(version, 102);
match run_cargo() {
Ok(behavior) => {
check_lock!(tc_result, "bar", which, behavior.bar, "1.0.2");
check_lock!(tc_result, "baz", which, behavior.baz, "1.0.1");
check_lock!(tc_result, "new-baz-dep", which, behavior.new_baz_dep, None);
}
Err(e) => {
if toolchain == "this" {
// baz can't lock to 1.0.1, it requires -Znamespaced-features
check_err_contains(&mut tc_result, e,
"error: failed to select a version for the requirement `baz = \"=1.0.1\"`\n\
candidate versions found which didn't match: 1.0.0"
if version <= &Version::new(1, 59, 0) {
check_lock!(tc_result, "bar", which, behavior.bar, "1.0.2");
check_lock!(tc_result, "baz", which, behavior.baz, "1.0.1");
check_lock!(tc_result, "new-baz-dep", which, behavior.new_baz_dep, None);
}
// Starting with 1.60, namespaced-features has been stabilized.
else {
check_lock!(tc_result, "bar", which, behavior.bar, "1.0.2");
check_lock!(tc_result, "baz", which, behavior.baz, "1.0.1");
check_lock!(
tc_result,
"new-baz-dep",
which,
behavior.new_baz_dep,
"1.0.0"
);
} else {
tc_result.push(format!("bar 1.0.2 locked build failed: {}", e));
}
}
Err(e) => {
// When version >= 1.51 and <= 1.59,
// baz can't lock to 1.0.1, it requires -Znamespaced-features
check_err_contains(
&mut tc_result,
e,
"candidate versions found which didn't match: 1.0.0",
);
}
}

unexpected_results.push(tc_result);
Expand Down Expand Up @@ -590,6 +619,11 @@ foo v0.1.0 [..]
#[cargo_test]
#[ignore]
fn avoids_split_debuginfo_collision() {
// Test needs two different toolchains.
// If the default toolchain is stable, then it won't work.
if default_toolchain_is_stable() {
return;
}
// Checks for a bug where .o files were being incorrectly shared between
// different toolchains using incremental and split-debuginfo on macOS.
let p = project()
Expand Down Expand Up @@ -637,7 +671,6 @@ fn avoids_split_debuginfo_collision() {
.cwd(p.root())
.with_stderr(
"\
[COMPILING] foo v0.1.0 [..]
[FINISHED] [..]
",
)
Expand Down

0 comments on commit 188298f

Please sign in to comment.