Skip to content

Commit dae4076

Browse files
author
Michael Wright
committed
Skip fmt test if rustfmt is unavailble
1 parent cc779c8 commit dae4076

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tests/fmt.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
1+
use std::process::Command;
2+
13
#[test]
24
#[ignore]
35
fn fmt() {
46
if option_env!("RUSTC_TEST_SUITE").is_some() {
57
return;
68
}
79

10+
// Skip this test if rustup nightly is unavailable
11+
let rustup_output = Command::new("rustup")
12+
.args(&["component", "list", "--toolchain", "nightly"])
13+
.output()
14+
.unwrap();
15+
assert!(rustup_output.status.success());
16+
let component_output = String::from_utf8_lossy(&rustup_output.stdout);
17+
if !component_output.contains("rustfmt") {
18+
return;
19+
}
20+
821
let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
922
let dev_dir = root_dir.join("clippy_dev");
10-
let output = std::process::Command::new("cargo")
23+
let output = Command::new("cargo")
1124
.current_dir(dev_dir)
1225
.args(&["+nightly", "run", "--", "fmt", "--check"])
1326
.output()

0 commit comments

Comments
 (0)