Skip to main content

ic_testkit/artifacts/
workspace.rs

1use std::path::{Path, PathBuf};
2
3/// Resolve the workspace root from a crate manifest directory.
4#[must_use]
5pub fn workspace_root_for(crate_manifest_dir: &str) -> PathBuf {
6    let manifest_dir = PathBuf::from(crate_manifest_dir);
7    if manifest_dir.parent().and_then(Path::file_name) == Some(std::ffi::OsStr::new("crates")) {
8        return manifest_dir
9            .parent()
10            .and_then(Path::parent)
11            .map(PathBuf::from)
12            .expect("workspace root");
13    }
14
15    manifest_dir
16}
17
18/// Return a stable target directory for host-side wasm test artifacts.
19#[must_use]
20pub fn test_target_dir(workspace_root: &Path, name: &str) -> PathBuf {
21    workspace_root.join("target").join(name)
22}