mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-25 10:27:56 +00:00
Ignore expansion test if cargo-expand subcommand isn't present
This commit is contained in:
@@ -4,6 +4,7 @@ version = "0.0.0"
|
|||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
build = "build.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
unstable = ["serde/unstable"]
|
unstable = ["serde/unstable"]
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
use std::env;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
const CARGO_EXPAND_BIN: &str = "cargo-expand";
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
const CARGO_EXPAND_BIN: &str = "cargo-expand.exe";
|
||||||
|
|
||||||
|
/// Scans paths in PATH env variable for a presence of `CARGO_EXPAND_BIN` file.
|
||||||
|
fn is_cargo_expand_present() -> bool {
|
||||||
|
if let Ok(var) = env::var("PATH") {
|
||||||
|
for path in var.split(":").map(PathBuf::from) {
|
||||||
|
let cargo_expand_path = path.join(CARGO_EXPAND_BIN);
|
||||||
|
if cargo_expand_path.exists() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn main() {
|
||||||
|
if is_cargo_expand_present() {
|
||||||
|
println!("cargo:rustc-cfg=cargo_expand");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
#[cfg(not(target_os = "emscripten"))]
|
#[cfg(not(target_os = "emscripten"))]
|
||||||
#[rustversion::attr(not(nightly), ignore)]
|
#[rustversion::attr(not(nightly), ignore)]
|
||||||
|
#[cfg_attr(not(cargo_expand), ignore)]
|
||||||
#[test]
|
#[test]
|
||||||
fn expandtest() {
|
fn expandtest() {
|
||||||
macrotest::expand("tests/expand/**/enum/*.rs");
|
macrotest::expand("tests/expand/**/enum/*.rs");
|
||||||
|
|||||||
Reference in New Issue
Block a user