mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-07-20 03:25:46 +00:00
Run expansion tests only if rustfmt is present
This commit is contained in:
+16
-9
@@ -1,13 +1,13 @@
|
||||
use std::process::{Command, ExitStatus, Stdio};
|
||||
|
||||
#[cfg(not(windows))]
|
||||
const CARGO_EXPAND: &str = "cargo-expand";
|
||||
fn has_cargo_expand() -> bool {
|
||||
let cargo_expand = if cfg!(windows) {
|
||||
"cargo-expand.exe"
|
||||
} else {
|
||||
"cargo-expand"
|
||||
};
|
||||
|
||||
#[cfg(windows)]
|
||||
const CARGO_EXPAND: &str = "cargo-expand.exe";
|
||||
|
||||
fn main() {
|
||||
if Command::new(CARGO_EXPAND)
|
||||
Command::new(cargo_expand)
|
||||
.arg("--version")
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::null())
|
||||
@@ -16,7 +16,14 @@ fn main() {
|
||||
.as_ref()
|
||||
.map(ExitStatus::success)
|
||||
.unwrap_or(false)
|
||||
{
|
||||
println!("cargo:rustc-cfg=cargo_expand");
|
||||
}
|
||||
|
||||
fn has_rustfmt() -> bool {
|
||||
toolchain_find::find_installed_component("rustfmt").is_some()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
if has_cargo_expand() && has_rustfmt() {
|
||||
println!("cargo:rustc-cfg=expandtest");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user