Disable tests in flycheck if cfg.setTest is set to false

This commit is contained in:
Chayim Refael Friedman 2025-07-21 16:34:12 +03:00
parent fa0320d077
commit f862bcc7f6
2 changed files with 10 additions and 1 deletions

View file

@ -2162,6 +2162,7 @@ impl Config {
extra_test_bin_args: self.runnables_extraTestBinaryArgs(source_root).clone(),
extra_env: self.extra_env(source_root).clone(),
target_dir: self.target_dir_from_config(source_root),
set_test: true,
}
}
@ -2219,6 +2220,7 @@ impl Config {
extra_test_bin_args: self.runnables_extraTestBinaryArgs(source_root).clone(),
extra_env: self.check_extra_env(source_root),
target_dir: self.target_dir_from_config(source_root),
set_test: *self.cfg_setTest(source_root),
},
ansi_color_output: self.color_diagnostic_output(),
},

View file

@ -31,6 +31,7 @@ pub(crate) enum InvocationStrategy {
pub(crate) struct CargoOptions {
pub(crate) target_tuples: Vec<String>,
pub(crate) all_targets: bool,
pub(crate) set_test: bool,
pub(crate) no_default_features: bool,
pub(crate) all_features: bool,
pub(crate) features: Vec<String>,
@ -54,7 +55,13 @@ impl CargoOptions {
cmd.args(["--target", target.as_str()]);
}
if self.all_targets {
cmd.arg("--all-targets");
if self.set_test {
cmd.arg("--all-targets");
} else {
// No --benches unfortunately, as this implies --tests (see https://github.com/rust-lang/cargo/issues/6454),
// and users setting `cfg.seTest = false` probably prefer disabling benches than enabling tests.
cmd.args(["--lib", "--bins", "--examples"]);
}
}
if self.all_features {
cmd.arg("--all-features");