Skip to content

Commit

Permalink
Auto merge of #9698 - ehuss:enable-future-incompat, r=alexcrichton
Browse files Browse the repository at this point in the history
Re-enable future-incompatible tests.

This re-enables the future-incompatible tests that were disabled in #9638.

rustc now has a `-Zfuture-incompat-test` flag we can use to test the future-incompatible reporting system. It causes rustc to treat every lint as future-incompatible, so we can just pick some arbitrary lint that should be stable over time.
  • Loading branch information
bors committed Jul 16, 2021
2 parents 27277d9 + f00a85a commit 2b4c8d9
Showing 1 changed file with 34 additions and 9 deletions.
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

0 comments on commit 2b4c8d9

Please sign in to comment.