//! Helpers shared by the integration tests. #![allow(dead_code, clippy::unwrap_used)] use std::fs; use std::path::Path; use lutra_vfs::{GlobalExcludes, Project, ProjectOptions}; use tempfile::TempDir; /// Creates a temporary directory with the given files; a path ending in `/` /// creates a directory. pub fn tree(paths: &[(&str, &str)]) -> TempDir { let dir = tempfile::tempdir().unwrap(); for (path, contents) in paths { let full = dir.path().join(path); if path.ends_with('/') { fs::create_dir_all(&full).unwrap(); } else { fs::create_dir_all(full.parent().unwrap()).unwrap(); fs::write(&full, contents).unwrap(); } } dir } /// Opens `dir` without the machine's global git excludes, so tests don't /// depend on the developer's configuration. pub fn open(dir: &Path) -> Project { Project::open_with( dir, ProjectOptions { global_excludes: GlobalExcludes::None, }, ) .unwrap() }