summaryrefslogtreecommitdiffstats
path: root/src/testutils.rs
blob: ade3ea1e423f057d46637ffda7c3c5e930349ba3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use assert_fs::fixture::{ChildPath, FixtureError};
use assert_fs::prelude::*;
use assert_fs::TempDir;
use std::path::{Path, PathBuf};

pub fn path_to(artifact: &str) -> PathBuf {
    [env!("CARGO_MANIFEST_DIR"), "testdata", artifact]
        .iter()
        .collect()
}

pub fn touch_testfile(testdir: &TempDir, relative_path: &Path) -> Result<ChildPath, FixtureError> {
    let testfile = testdir.child(relative_path);
    testfile.touch()?;
    Ok(testfile)
}