Ignore expansion test if cargo-expand subcommand isn't present
This commit is contained in:
parent
640f8e0e82
commit
9a0e4e0176
@ -4,6 +4,7 @@ version = "0.0.0"
|
||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||
edition = "2018"
|
||||
publish = false
|
||||
build = "build.rs"
|
||||
|
||||
[features]
|
||||
unstable = ["serde/unstable"]
|
||||
|
28
test_suite/build.rs
Normal file
28
test_suite/build.rs
Normal file
@ -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"))]
|
||||
#[rustversion::attr(not(nightly), ignore)]
|
||||
#[cfg_attr(not(cargo_expand), ignore)]
|
||||
#[test]
|
||||
fn expandtest() {
|
||||
macrotest::expand("tests/expand/**/enum/*.rs");
|
||||
|
Loading…
x
Reference in New Issue
Block a user