97001e1544
Move all 29 workspace members from packages/<name>/ to crates/<name>/. Updates: workspace Cargo.toml (members + path deps), justfile, root CLAUDE.md, scripts/build/CARGO_INSTALL.md, docs/architecture/crates.md (renamed from packages.md), structural references in docs/architecture and docs/configuration, per-crate CLAUDE.md self-references. Historical plans, reports, and building/ docs are left untouched. No behavior change; just check-all stays green and fermata tests pass.
70 lines
1.9 KiB
Rust
70 lines
1.9 KiB
Rust
use dirigent_fermata::core::project::find_project_root;
|
|
use std::fs;
|
|
use tempfile::TempDir;
|
|
|
|
#[test]
|
|
fn finds_botignore_toml_first() {
|
|
let tmp = TempDir::new().unwrap();
|
|
let root = tmp.path();
|
|
fs::create_dir_all(root.join("sub/deep")).unwrap();
|
|
fs::write(root.join("botignore.toml"), "").unwrap();
|
|
fs::write(root.join(".botignore"), "").unwrap();
|
|
fs::create_dir_all(root.join(".git")).unwrap();
|
|
|
|
let target = root.join("sub/deep/file.rs");
|
|
fs::write(&target, "").unwrap();
|
|
|
|
let found = find_project_root(&target).unwrap();
|
|
assert_eq!(found, root);
|
|
}
|
|
|
|
#[test]
|
|
fn falls_back_to_botignore() {
|
|
let tmp = TempDir::new().unwrap();
|
|
let root = tmp.path();
|
|
fs::create_dir_all(root.join("sub")).unwrap();
|
|
fs::write(root.join(".botignore"), "").unwrap();
|
|
|
|
let target = root.join("sub/file.rs");
|
|
fs::write(&target, "").unwrap();
|
|
|
|
let found = find_project_root(&target).unwrap();
|
|
assert_eq!(found, root);
|
|
}
|
|
|
|
#[test]
|
|
fn falls_back_to_git() {
|
|
let tmp = TempDir::new().unwrap();
|
|
let root = tmp.path();
|
|
fs::create_dir_all(root.join("sub")).unwrap();
|
|
fs::create_dir_all(root.join(".git")).unwrap();
|
|
|
|
let target = root.join("sub/file.rs");
|
|
fs::write(&target, "").unwrap();
|
|
|
|
let found = find_project_root(&target).unwrap();
|
|
assert_eq!(found, root);
|
|
}
|
|
|
|
#[test]
|
|
fn returns_none_when_no_marker() {
|
|
let tmp = TempDir::new().unwrap();
|
|
let target = tmp.path().join("file.rs");
|
|
std::fs::write(&target, "").unwrap();
|
|
assert!(find_project_root(&target).is_none());
|
|
}
|
|
|
|
#[test]
|
|
fn walks_up_from_file_path_not_cwd() {
|
|
let tmp = TempDir::new().unwrap();
|
|
let root = tmp.path();
|
|
fs::create_dir_all(root.join("a/b/c")).unwrap();
|
|
fs::write(root.join("a/.botignore"), "").unwrap();
|
|
|
|
let target = root.join("a/b/c/file.rs");
|
|
fs::write(&target, "").unwrap();
|
|
|
|
let found = find_project_root(&target).unwrap();
|
|
assert_eq!(found, root.join("a"));
|
|
}
|