Skip to content

./x test clippy does not honor --test-args #143824

@RalfJung

Description

@RalfJung

Summary

./x test clippy does not support filtering tests the way other test suites do, by passing --test-args.

Command used

./x test clippy --stage 1 --test-args line

Expected behaviour

Only the tests with the word "line" in the file get run. (C.f. ./x test miri -- atomic).

Actual behaviour

All tests get run.

More details

The logic that makes this work in Miri is here:

cargo.arg("--").args(builder.config.test_args());

There's something in clippy that seems related but I don't understand any part of it:

// Collect paths of tests to run
'partially_test: {
let paths = &builder.config.paths[..];
let mut test_names = Vec::new();
for path in paths {
if let Some(path) =
helpers::is_valid_test_suite_arg(path, "src/tools/clippy/tests", builder)
{
test_names.push(path);
} else if path.ends_with("src/tools/clippy") {
// When src/tools/clippy is called directly, all tests should be run.
break 'partially_test;
}
}
cargo.env("TESTNAME", test_names.join(","));
}

Also the logic inside clippy's ui test runner is odd -- usually, Rust test suites take their test filter form the command-line arguments. Here's Miri doing that:

let mut args = ui_test::Args::test()?;

We don't even have to do anything, ui_test just does this by default.

Clippy also does this...

let mut args = Args::test().unwrap();

... but then it overwrites the resulting filter for some reason:

filter_files: env::var("TESTNAME")

Is there a reason clippy makes this different from every other crate I have ever seen?

Cc @flip1995 @oli-obk @Kobzol

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-clippyArea: ClippyC-bugCategory: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions