Skip to content

Commit bc4c65c

Browse files
committed
Do not run formats_source if rustfmt is not available
Generalized `clippy_is_available` and renamed as `command_is_available`. No checks in `ignores_failure_to_format_source`, it's not supposed to use `rustfmt` even if it's available
1 parent 68a1c78 commit bc4c65c

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

crates/cargo-test-support/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,9 +1801,9 @@ pub fn slow_cpu_multiplier(main: u64) -> Duration {
18011801
Duration::from_secs(*SLOW_CPU_MULTIPLIER * main)
18021802
}
18031803

1804-
pub fn clippy_is_available() -> bool {
1805-
if let Err(e) = process("clippy-driver").arg("-V").exec_with_output() {
1806-
eprintln!("clippy-driver not available, skipping clippy test");
1804+
pub fn command_is_available(cmd: &str) -> bool {
1805+
if let Err(e) = process(cmd).arg("-V").exec_with_output() {
1806+
eprintln!("{} not available, skipping tests", cmd);
18071807
eprintln!("{:?}", e);
18081808
false
18091809
} else {

tests/testsuite/cache_messages.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Tests for caching compiler diagnostics.
22
33
use cargo_test_support::{
4-
basic_manifest, clippy_is_available, is_coarse_mtime, process, project, registry::Package,
4+
basic_manifest, command_is_available, is_coarse_mtime, process, project, registry::Package,
55
sleep_ms,
66
};
77
use std::path::Path;
@@ -276,7 +276,7 @@ fn fix() {
276276

277277
#[cargo_test]
278278
fn clippy() {
279-
if !clippy_is_available() {
279+
if !command_is_available("clippy-driver") {
280280
return;
281281
}
282282

tests/testsuite/clippy.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//! Tests for the `cargo clippy` command.
22
3-
use cargo_test_support::{clippy_is_available, project, registry::Package};
3+
use cargo_test_support::{command_is_available, project, registry::Package};
44

55
#[cargo_test]
66
// Clippy should never be considered fresh.
77
fn clippy_force_rebuild() {
8-
if !clippy_is_available() {
8+
if !command_is_available("clippy-driver") {
99
return;
1010
}
1111

@@ -43,7 +43,7 @@ fn clippy_force_rebuild() {
4343

4444
#[cargo_test]
4545
fn clippy_passes_args() {
46-
if !clippy_is_available() {
46+
if !command_is_available("clippy-driver") {
4747
return;
4848
}
4949

tests/testsuite/fix.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::fs::File;
44

55
use cargo_test_support::git;
6-
use cargo_test_support::{basic_manifest, clippy_is_available, project};
6+
use cargo_test_support::{basic_manifest, command_is_available, project};
77

88
use std::io::Write;
99

@@ -1253,7 +1253,7 @@ fn fix_in_existing_repo_weird_ignore() {
12531253

12541254
#[cargo_test]
12551255
fn fix_with_clippy() {
1256-
if !clippy_is_available() {
1256+
if !command_is_available("clippy-driver") {
12571257
return;
12581258
}
12591259

tests/testsuite/init.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::fs::{self, File};
66
use std::io::prelude::*;
77
use std::process::Command;
88

9-
use cargo_test_support::{paths, Execs};
9+
use cargo_test_support::{command_is_available, paths, Execs};
1010

1111
fn cargo_process(s: &str) -> Execs {
1212
let mut execs = cargo_test_support::cargo_process(s);
@@ -660,6 +660,10 @@ fn no_filename() {
660660

661661
#[cargo_test]
662662
fn formats_source() {
663+
if !command_is_available("rustfmt") {
664+
return;
665+
}
666+
663667
fs::write(&paths::root().join("rustfmt.toml"), "tab_spaces = 2").unwrap();
664668

665669
cargo_process("init --lib")

0 commit comments

Comments
 (0)