macro_rules! resolve_snap_path {
() => {{
let workspace = insta::_get_workspace_root!();
let function_name = insta::_function_name!();
let snap_name = function_name
.rsplit("::")
.next()
.expect("function name should have segments");
let module_prefix = module_path!().replace("::", "__");
let snap_filename = format!("{module_prefix}__{snap_name}.snap");
workspace
.join(
std::path::Path::new(file!())
.parent()
.expect("source file should have parent directory"),
)
.join("snapshots")
.join(&snap_filename)
}};
}
macro_rules! normalize_snapshots {
($snapshot:expr) => {
if is_deterministic() {
$snapshot
} else {
let mut files = $snapshot;
let snap_path = resolve_snap_path!();
crate::utils::patch_platform_dependent_fields(&mut files, &snap_path);
files
}
};
}
macro_rules! assert_inspect_snapshot {
($output:expr) => {
if is_deterministic() {
insta::assert_snapshot!($output);
} else {
let snap_path = resolve_snap_path!();
crate::utils::assert_line_count(&$output, &snap_path);
}
};
}
pub(crate) use assert_inspect_snapshot;
pub(crate) use normalize_snapshots;
pub(crate) use resolve_snap_path;