Files
vectorcraft/crates/mcp/tests/common/mod.rs
T
dotCooCoo 940b47234b Tests: the vectorcraft-mcp integration tests remove their temp folders
automation_roots.rs and protocol_props.rs wrote their files into folders
made by vectorcraft_testkit::temp_dir (vectorcraft-testkit-roots-<tag>-<pid>,
mcp-junk, mcp-confined), and nothing removed them after the run.

A shared tests/common module adds TempFolder, which takes the folder from
temp_dir, with its checks against a folder made by another user, and
removes it with everything in it when dropped, also when the test panics,
as the findfiles tests' Tree guard does
(crates/engine/src/cmd/findfiles/tests.rs:49). Each proptest case of
a_confined_server_writes_only_inside_its_root now gets a new folder. A new
test checks that the folder is removed on drop and after a panic.
2026-11-13 08:22:23 -08:00

29 lines
772 B
Rust

//! Shared helpers for the MCP integration tests.
use std::path::{Path, PathBuf};
/// A test's own folder, made by [`vectorcraft_testkit::temp_dir`] (with its checks against a
/// folder made by someone else) and removed with everything in it when dropped, also when the
/// test panics. A removal that fails (a file still open) is ignored. Tests that run at the same
/// time use different tags.
pub struct TempFolder(PathBuf);
impl TempFolder {
pub fn new(tag: &str) -> Self {
Self(vectorcraft_testkit::temp_dir(tag))
}
}
impl std::ops::Deref for TempFolder {
type Target = Path;
fn deref(&self) -> &Path {
&self.0
}
}
impl Drop for TempFolder {
fn drop(&mut self) {
let _ = std::fs::remove_dir_all(&self.0);
}
}