summaryrefslogtreecommitdiffstats
path: root/src/testutils.rs
blob: 1cc3fd4dd2283cc3c8abf45352997cf1785a00e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use assert_fs::fixture::{ChildPath, FixtureError};
use assert_fs::prelude::*;
use assert_fs::TempDir;
use std::fs;
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)
}