#![allow(dead_code)]
use std::path::PathBuf;
use shared_target_core::{Report, Strategy};
const EXPECTED: &str = "CARGO_SHARED_TARGET_EXPECT_STRATEGY";
const OTHER_DEVICE: &str = "CARGO_SHARED_TARGET_OTHER_DEVICE_DIR";
pub fn name(strategy: Strategy) -> &'static str {
match strategy {
Strategy::Clone => "clone",
Strategy::LinkAndCopy => "link-and-copy",
}
}
pub fn assert_expected_strategy(report: &Report) {
let Some(expected) = std::env::var_os(EXPECTED) else {
return;
};
let expected = expected.to_string_lossy().to_ascii_lowercase();
let actual = name(report.strategy);
assert_eq!(
actual, expected,
"{EXPECTED} asked for `{expected}` and the seeding did `{actual}`; \
the filesystem under TMPDIR is not the one this job meant to test"
);
}
pub fn other_device() -> Option<PathBuf> {
std::env::var_os(OTHER_DEVICE).map(PathBuf::from)
}