diff --git a/tests/testsuite/old_cargos.rs b/tests/testsuite/old_cargos.rs index b3d1e3ca5d5..aa07757785d 100644 --- a/tests/testsuite/old_cargos.rs +++ b/tests/testsuite/old_cargos.rs @@ -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. // @@ -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)); @@ -449,16 +468,14 @@ 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", + ); } } @@ -466,21 +483,33 @@ fn new_features() { 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); @@ -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() @@ -637,7 +671,6 @@ fn avoids_split_debuginfo_collision() { .cwd(p.root()) .with_stderr( "\ -[COMPILING] foo v0.1.0 [..] [FINISHED] [..] ", )