Debian Codegraph @

tests/helper/mod.rs

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 // SPDX-License-Identifier: Apache-2.0 OR MIT
2
3 use std::{
4 path::{Path, PathBuf},
5 str,
6 };
7
8 pub(crate) use fs_err as fs;
9
10 pub(crate) fn fixtures_dir() -> &'static Path {
11 Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures"))
12 }
13
14 #[track_caller]
15 pub(crate) fn test_project(model: &str) -> (tempfile::TempDir, PathBuf) {
16 let tmpdir = tempfile::tempdir().unwrap();
17 let tmpdir_path = tmpdir.path();
18
19 let model_path;
20 let workspace_root;
21 if model.contains('/') {
22 let mut model = model.splitn(2, '/');
23 model_path = fixtures_dir().join(model.next().unwrap());
24 workspace_root = tmpdir_path.join(model.next().unwrap());
25 assert!(model.next().is_none());
26 } else {
27 model_path = fixtures_dir().join(model);
28 workspace_root = tmpdir_path.to_path_buf();
29 }
30
31 test_helper::git::copy_tracked_files(model_path, tmpdir_path);
32 (tmpdir, workspace_root)
33 }