|
// TEMPORARY smoke test (throwaway, delete after). |
|
// Uses the exact [ignore].patterns from ~/.config/vaultsync/config.toml verbatim. |
|
use vaultsync::IgnoreSet; |
|
|
|
fn real_patterns() -> Vec<String> { |
|
[ |
|
".venv-trading/", |
|
".lit/", |
|
".playwright-cli/", |
|
".whisper_work/", |
|
"_ocr_work/", |
|
".ipynb_checkpoints/", |
|
"__pycache__/", |
|
".git/", |
|
".trash/", |
|
".DS_Store", |
|
".obsidian/workspace", |
|
".obsidian/workspace.json", |
|
".obsidian/workspace-mobile.json", |
|
] |
|
.iter() |
|
.map(|s| s.to_string()) |
|
.collect() |
|
} |
|
|
|
#[test] |
|
fn real_config_smoke() { |
|
let set = IgnoreSet::from_patterns(&real_patterns()).unwrap(); |
|
|
|
// Cases with expected result: <key, expect_ignored> |
|
let cases: &[(&str, bool, &str)] = &[ |
|
// Runtime junk (dir prefixes, vault-rooted) |
|
(".venv-trading/lib/site.py", true, ".venv-trading/ child"), |
|
(".lit/log", true, ".lit/ child"), |
|
(".playwright-cli/download", true, ".playwright-cli/ child"), |
|
(".whisper_work/seg", true, ".whisper_work/ child"), |
|
("_ocr_work/page.png", true, "_ocr_work/ child"), |
|
(".ipynb_checkpoints/x.json", true, ".ipynb_checkpoints/ child"), |
|
("__pycache__/foo.cpython-312.pyc", true, "__pycache__/ child"), |
|
("__pycache__/", true, "__pycache__/ folder itself"), |
|
// These are vault-ROOT dir prefixes: nested copies are NOT ignored |
|
// (pin: no basename-dir behavior). Same as .trash/. |
|
("notes/.lit/foo", false, "nested .lit/ NOT a root prefix"), |
|
("notes/__pycache__/x", false, "nested __pycache__/ NOT root"), |
|
("notes/_ocr_work/", false, "nested _ocr_work/ NOT root"), |
|
// VCS defaults |
|
(".git/HEAD", true, ".git/ child"), |
|
(".git/", true, ".git/ folder itself"), |
|
(".trash/old.md", true, ".trash/ child"), |
|
("notes/.DS_Store", true, "basename .DS_Store anywhere"), |
|
(".DS_Store", true, "root .DS_Store"), |
|
(".DS_STORE", false, "case-sensitive: .DS_STORE no"), |
|
("DS_Store.bak", false, "DS_Store.bak no"), |
|
// Obsidian workspace trio (exact) |
|
(".obsidian/workspace", true, "exact workspace"), |
|
(".obsidian/workspace.json", true, "exact workspace.json"), |
|
(".obsidian/workspace-mobile.json", true, "exact workspace-mobile.json"), |
|
(".obsidian/workspace.backup.json", false, "workspace.backup.json no"), |
|
// Real vault content must NOT be ignored |
|
("notes/foo.md", false, "normal note"), |
|
(".obsidian/app.json", false, "obsidian app.json kept"), |
|
("daily/2025-08-30.md", false, "normal daily note"), |
|
]; |
|
|
|
let mut fails = 0; |
|
for (key, expect, label) in cases { |
|
let got = set.matches(key); |
|
let ok = got == *expect; |
|
if !ok { |
|
fails += 1; |
|
} |
|
println!( |
|
"{} key={:<40} expect={:<5} got={:<5} {}", |
|
if ok { "PASS" } else { "FAIL" }, |
|
key, |
|
expect, |
|
got, |
|
label |
|
); |
|
} |
|
|
|
if fails > 0 { |
|
panic!("{fails} case(s) had unexpected results"); |
|
} |
|
println!("ALL smoke cases passed"); |
|
} |