testing/
paths.rs

1use std::{env, path::PathBuf, sync::Arc};
2
3use once_cell::sync::Lazy;
4
5pub fn manifest_dir() -> PathBuf {
6    env::var("CARGO_MANIFEST_DIR")
7        .map(PathBuf::from)
8        .map(|p| {
9            p.canonicalize()
10                .expect("failed to canonicalize `CARGO_MANIFEST_DIR`")
11        })
12        .unwrap_or_else(|err| panic!("failed to read `CARGO_MANIFEST_DIR`: {err}"))
13}
14
15/// This directory is per-crate.
16pub fn test_results_dir() -> Arc<PathBuf> {
17    fn detect() -> PathBuf {
18        manifest_dir().join("target").join("swc-test-results")
19    }
20
21    static DIR: Lazy<Arc<PathBuf>> = Lazy::new(|| Arc::new(detect()));
22
23    DIR.clone()
24}