pub trait TestProject {
// Required method
fn root(&self) -> &Path;
// Provided methods
fn add_file(
&self,
relative_path: &str,
content: &str,
) -> Result<PathBuf, TestProjectError> { ... }
fn file_uri(&self, relative_path: &str) -> Uri { ... }
fn file_path_str(&self, relative_path: &str) -> String { ... }
}Expand description
Scaffolds temporary projects for integration testing against real language servers.
Enable with the testing feature flag:
aether-lspd = { version = "...", features = ["testing"] }§TestProject trait
All test projects implement TestProject, which provides:
root()– The temporary directory path.add_file(path, content)– Write a file relative to the project root.file_uri(path)– Get an LSPfile://URI for a relative path.file_path_str(path)– Get the absolute path as a string.
§Implementations
CargoProject::new(name)– Creates a temporary Cargo project withCargo.tomlandsrc/main.rs.NodeProject::new(name)– Creates a temporary Node.js/TypeScript project withpackage.json,tsconfig.json,src/index.ts, and runsnpm install typescript.
Both are backed by TempDir and are automatically cleaned up when dropped.
§Example
use aether_lspd::testing::{CargoProject, TestProject};
let project = CargoProject::new("my-test").unwrap();
project.add_file("src/lib.rs", "pub fn hello() -> &'static str { \"hi\" }").unwrap();
let uri = project.file_uri("src/lib.rs");