Skip to content

Use 1.51.0 in old cargos test #10167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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