Skip to content

Change env var used for testing Clippy #6575

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 1 commit into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
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
10 changes: 7 additions & 3 deletions doc/adding_lints.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,14 @@ add `// edition:2018` at the top of the test file (note that it's space-sensitiv

Manually testing against an example file can be useful if you have added some
`println!`s and the test suite output becomes unreadable. To try Clippy with
your local modifications, run `env CLIPPY_TESTS=true cargo run --bin
clippy-driver -- -L ./target/debug input.rs` from the working copy root.
your local modifications, run

With tests in place, let's have a look at implementing our lint now.
```
env __CLIPPY_INTERNAL_TESTS=true cargo run --bin clippy-driver -- -L ./target/debug input.rs
```

from the working copy root. With tests in place, let's have a look at
implementing our lint now.

## Lint declaration

Expand Down
2 changes: 1 addition & 1 deletion src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ pub fn main() {
// - IF Clippy is run on the main crate, not on deps (`!cap_lints_allow`) THEN
// - IF `--no-deps` is not set (`!no_deps`) OR
// - IF `--no-deps` is set and Clippy is run on the specified primary package
let clippy_tests_set = env::var("CLIPPY_TESTS").map_or(false, |val| val == "true");
let clippy_tests_set = env::var("__CLIPPY_INTERNAL_TESTS").map_or(false, |val| val == "true");
let cap_lints_allow = arg_value(&orig_args, "--cap-lints", |val| val == "allow").is_some();
let in_primary_package = env::var("CARGO_PRIMARY_PACKAGE").is_ok();

Expand Down
2 changes: 1 addition & 1 deletion tests/compile-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ fn run_ui_cargo(config: &mut compiletest::Config) {

fn prepare_env() {
set_var("CLIPPY_DISABLE_DOCS_LINKS", "true");
set_var("CLIPPY_TESTS", "true");
set_var("__CLIPPY_INTERNAL_TESTS", "true");
//set_var("RUST_BACKTRACE", "0");
}

Expand Down