diff options
Diffstat (limited to 'src/tools/clippy/tests/cargo/mod.rs')
| -rw-r--r-- | src/tools/clippy/tests/cargo/mod.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/cargo/mod.rs b/src/tools/clippy/tests/cargo/mod.rs new file mode 100644 index 00000000000..3c385343f70 --- /dev/null +++ b/src/tools/clippy/tests/cargo/mod.rs @@ -0,0 +1,29 @@ +use lazy_static::lazy_static; +use std::env; +use std::path::PathBuf; + +lazy_static! { + pub static ref CARGO_TARGET_DIR: PathBuf = { + match env::var_os("CARGO_TARGET_DIR") { + Some(v) => v.into(), + None => env::current_dir().unwrap().join("target"), + } + }; + pub static ref TARGET_LIB: PathBuf = { + if let Some(path) = option_env!("TARGET_LIBS") { + path.into() + } else { + let mut dir = CARGO_TARGET_DIR.clone(); + if let Some(target) = env::var_os("CARGO_BUILD_TARGET") { + dir.push(target); + } + dir.push(env!("PROFILE")); + dir + } + }; +} + +#[must_use] +pub fn is_rustc_test_suite() -> bool { + option_env!("RUSTC_TEST_SUITE").is_some() +} |
