Skip to content
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

Re-enable future-incompatible tests. #9698

Merged
merged 1 commit into from
Jul 16, 2021
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
43 changes: 34 additions & 9 deletions tests/testsuite/future_incompat_report.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
//! Tests for future-incompat-report messages
//!
//! Note that these tests use the -Zfuture-incompat-test for rustc.
//! This causes rustc to treat *every* lint as future-incompatible.
//! This is done because future-incompatible lints are inherently
//! ephemeral, but we don't want to continually update these tests.
//! So we pick some random lint that will likely always be the same
//! over time.

use cargo_test_support::registry::Package;
use cargo_test_support::{basic_manifest, is_nightly, project, Project};

// An arbitrary lint (array_into_iter) that triggers a report.
const FUTURE_EXAMPLE: &'static str = "fn main() { [true].into_iter(); }";
// An arbitrary lint (unused_variables) that triggers a lint.
// We use a special flag to force it to generate a report.
const FUTURE_EXAMPLE: &'static str = "fn main() { let x = 1; }";
// Some text that will be displayed when the lint fires.
const FUTURE_OUTPUT: &'static str = "[..]array_into_iter[..]";
const FUTURE_OUTPUT: &'static str = "[..]unused_variables[..]";

fn simple_project() -> Project {
project()
Expand All @@ -17,9 +25,15 @@ fn simple_project() -> Project {

#[cargo_test]
fn no_output_on_stable() {
if !is_nightly() {
// -Zfuture-incompat-test requires nightly (permanently)
return;
}
let p = simple_project();

p.cargo("build")
p.cargo("check")
// Even though rustc emits the report, cargo ignores it without -Z.
.env("RUSTFLAGS", "-Zfuture-incompat-test")
.with_stderr_contains(FUTURE_OUTPUT)
.with_stderr_does_not_contain("[..]cargo report[..]")
.run();
Expand Down Expand Up @@ -58,6 +72,7 @@ fn gate_future_incompat_report() {
#[cargo_test]
fn test_zero_future_incompat() {
if !is_nightly() {
// -Zfuture-incompat-test requires nightly (permanently)
return;
}

Expand All @@ -69,6 +84,7 @@ fn test_zero_future_incompat() {
// No note if --future-incompat-report is not specified.
p.cargo("build -Z future-incompat-report")
.masquerade_as_nightly_cargo()
.env("RUSTFLAGS", "-Zfuture-incompat-test")
.with_stderr(
"\
[COMPILING] foo v0.0.0 [..]
Expand All @@ -79,6 +95,7 @@ fn test_zero_future_incompat() {

p.cargo("build --future-incompat-report -Z unstable-options -Z future-incompat-report")
.masquerade_as_nightly_cargo()
.env("RUSTFLAGS", "-Zfuture-incompat-test")
.with_stderr(
"\
[FINISHED] [..]
Expand All @@ -89,9 +106,9 @@ note: 0 dependencies had future-incompatible warnings
}

#[cargo_test]
#[ignore] // Waiting on https://github.com/rust-lang/rust/pull/86478
fn test_single_crate() {
if !is_nightly() {
// -Zfuture-incompat-test requires nightly (permanently)
return;
}

Expand All @@ -100,13 +117,15 @@ fn test_single_crate() {
for command in &["build", "check", "rustc", "test"] {
p.cargo(command).arg("-Zfuture-incompat-report")
.masquerade_as_nightly_cargo()
.env("RUSTFLAGS", "-Zfuture-incompat-test")
.with_stderr_contains(FUTURE_OUTPUT)
.with_stderr_contains("warning: the following packages contain code that will be rejected by a future version of Rust: foo v0.0.0 [..]")
.with_stderr_does_not_contain("[..]incompatibility[..]")
.run();

p.cargo(command).arg("-Zfuture-incompat-report").arg("-Zunstable-options").arg("--future-incompat-report")
.masquerade_as_nightly_cargo()
.env("RUSTFLAGS", "-Zfuture-incompat-test")
.with_stderr_contains(FUTURE_OUTPUT)
.with_stderr_contains("warning: the following packages contain code that will be rejected by a future version of Rust: foo v0.0.0 [..]")
.with_stderr_contains("The package `foo v0.0.0 ([..])` currently triggers the following future incompatibility lints:")
Expand All @@ -115,9 +134,9 @@ fn test_single_crate() {
}

#[cargo_test]
#[ignore] // Waiting on https://github.com/rust-lang/rust/pull/86478
fn test_multi_crate() {
if !is_nightly() {
// -Zfuture-incompat-test requires nightly (permanently)
return;
}

Expand Down Expand Up @@ -147,6 +166,7 @@ fn test_multi_crate() {
for command in &["build", "check", "rustc", "test"] {
p.cargo(command).arg("-Zfuture-incompat-report")
.masquerade_as_nightly_cargo()
.env("RUSTFLAGS", "-Zfuture-incompat-test")
.with_stderr_does_not_contain(FUTURE_OUTPUT)
.with_stderr_contains("warning: the following packages contain code that will be rejected by a future version of Rust: first-dep v0.0.1, second-dep v0.0.2")
// Check that we don't have the 'triggers' message shown at the bottom of this loop
Expand All @@ -155,6 +175,7 @@ fn test_multi_crate() {

p.cargo(command).arg("-Zunstable-options").arg("-Zfuture-incompat-report").arg("--future-incompat-report")
.masquerade_as_nightly_cargo()
.env("RUSTFLAGS", "-Zfuture-incompat-test")
.with_stderr_contains("warning: the following packages contain code that will be rejected by a future version of Rust: first-dep v0.0.1, second-dep v0.0.2")
.with_stderr_contains("The package `first-dep v0.0.1` currently triggers the following future incompatibility lints:")
.with_stderr_contains("The package `second-dep v0.0.2` currently triggers the following future incompatibility lints:")
Expand All @@ -164,6 +185,7 @@ fn test_multi_crate() {
// Test that passing the correct id via '--id' doesn't generate a warning message
let output = p
.cargo("build -Z future-incompat-report")
.env("RUSTFLAGS", "-Zfuture-incompat-test")
.masquerade_as_nightly_cargo()
.exec_with_output()
.unwrap();
Expand Down Expand Up @@ -223,15 +245,16 @@ fn test_multi_crate() {
}

#[cargo_test]
#[ignore] // Waiting on https://github.com/rust-lang/rust/pull/86478
fn color() {
if !is_nightly() {
// -Zfuture-incompat-test requires nightly (permanently)
return;
}

let p = simple_project();

p.cargo("check -Zfuture-incompat-report")
.env("RUSTFLAGS", "-Zfuture-incompat-test")
.masquerade_as_nightly_cargo()
.run();

Expand All @@ -248,9 +271,9 @@ fn color() {
}

#[cargo_test]
#[ignore] // Waiting on https://github.com/rust-lang/rust/pull/86478
fn bad_ids() {
if !is_nightly() {
// -Zfuture-incompat-test requires nightly (permanently)
return;
}

Expand All @@ -263,6 +286,7 @@ fn bad_ids() {
.run();

p.cargo("check -Zfuture-incompat-report")
.env("RUSTFLAGS", "-Zfuture-incompat-test")
.masquerade_as_nightly_cargo()
.run();

Expand All @@ -285,9 +309,9 @@ Available IDs are: 1
}

#[cargo_test]
#[ignore] // Waiting on https://github.com/rust-lang/rust/pull/86478
fn suggestions_for_updates() {
if !is_nightly() {
// -Zfuture-incompat-test requires nightly (permanently)
return;
}

Expand Down Expand Up @@ -341,6 +365,7 @@ fn suggestions_for_updates() {

p.cargo("check -Zfuture-incompat-report")
.masquerade_as_nightly_cargo()
.env("RUSTFLAGS", "-Zfuture-incompat-test")
.with_stderr_contains("[..]cargo report future-incompatibilities --id 1[..]")
.run();

Expand Down