Skip to content

Commit

Permalink
Auto merge of #11699 - epage:warn, r=ehuss
Browse files Browse the repository at this point in the history
Deny warnings in CI, not locally

### What does this PR try to resolve?

The problem with #![deny(warnings)] is it makes iteration more difficult as you might have intermediate states with warnings. Its slightly better that we defer this to cargo test --lib but that still means you can't run a subset of tests against your experiment until you've cleaned up all of your warnings. This can lead to users [working around the problem which could accidentally slip in](d92d048).

### How should we test and review this PR?

The first round for this PR includes a warning in the `cargo` crate to ensure it breaks CI.  It will then be reverted.

### Additional information

See also https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/.60.23!.5Bcfg_attr.28test.2C.20deny.28warnings.29.29.5D.60
  • Loading branch information
bors committed Feb 11, 2023
2 parents 7113896 + d52f298 commit 35e45fd
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 11 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ jobs:
CARGO_PROFILE_TEST_DEBUG: 1
CARGO_INCREMENTAL: 0
CARGO_PUBLIC_NETWORK_TESTS: 1
# Deny warnings on CI to avoid warnings getting into the codebase.
RUSTFLAGS: -D warnings
strategy:
matrix:
include:
Expand Down Expand Up @@ -85,8 +87,7 @@ jobs:
run: echo CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse >> $GITHUB_ENV
if: "!contains(matrix.rust, 'stable')"

# Deny warnings on CI to avoid warnings getting into the codebase.
- run: cargo test --features 'deny-warnings'
- run: cargo test
# The testsuite generates a huge amount of data, and fetch-smoke-test was
# running out of disk space.
- name: Clear test output
Expand All @@ -100,8 +101,8 @@ jobs:
run: |
# This only tests `cargo fix` because fix-proxy-mode is one of the most
# complicated subprocess management in Cargo.
cargo test --test testsuite --features 'deny-warnings' -- fix::
- run: cargo test --features 'deny-warnings' --manifest-path crates/cargo-test-support/Cargo.toml
cargo test --test testsuite -- fix::
- run: cargo test --manifest-path crates/cargo-test-support/Cargo.toml
env:
CARGO_TARGET_DIR: target
- run: cargo test -p cargo-platform
Expand Down
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ test = false
doc = false

[features]
deny-warnings = []
vendored-openssl = ["openssl/vendored"]
vendored-libgit2 = ["libgit2-sys/vendored"]
pretty-env-logger = ["pretty_env_logger"]
3 changes: 0 additions & 3 deletions crates/cargo-test-support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,3 @@ url = "2.2.2"

[target.'cfg(windows)'.dependencies]
windows-sys = { version = "0.45.0", features = ["Win32_Storage_FileSystem"] }

[features]
deny-warnings = []
1 change: 0 additions & 1 deletion crates/cargo-test-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//! See <https://rust-lang.github.io/cargo/contrib/> for a guide on writing tests.
#![allow(clippy::all)]
#![cfg_attr(feature = "deny-warnings", deny(warnings))]

use std::env;
use std::ffi::OsStr;
Expand Down
1 change: 0 additions & 1 deletion src/cargo/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// For various reasons, some idioms are still allow'ed, but we would like to
// test and enforce them.
#![warn(rust_2018_idioms)]
#![cfg_attr(test, deny(warnings))]
// Due to some of the default clippy lints being somewhat subjective and not
// necessarily an improvement, we prefer to not use them at this time.
#![allow(clippy::all)]
Expand Down
1 change: 0 additions & 1 deletion tests/testsuite/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// See src/cargo/lib.rs for notes on these lint settings.
#![warn(rust_2018_idioms)]
#![allow(clippy::all)]
#![cfg_attr(feature = "deny-warnings", deny(warnings))]

#[macro_use]
extern crate cargo_test_macro;
Expand Down

0 comments on commit 35e45fd

Please sign in to comment.