From c3b5099014b3d622b9506d38fa20dd16be090890 Mon Sep 17 00:00:00 2001 From: claude Date: Sun, 12 Jul 2026 19:33:43 +0200 Subject: [PATCH] =?UTF-8?q?test(cli):=20RED=20=E2=80=94=20a=20missing=20[n?= =?UTF-8?q?odes]=20dir=20leaks=20the=20cargo=20metadata=20error=20(#245)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RED pin: a_missing_nodes_pointer_dir_refuses_without_the_cargo_metadata_leak (project.rs unit tests) — the refusal must name the absent directory and keep the [nodes] context, with no cargo-metadata wrap. refs #245 --- crates/aura-cli/src/project.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/crates/aura-cli/src/project.rs b/crates/aura-cli/src/project.rs index cb36bba..e9d4db6 100644 --- a/crates/aura-cli/src/project.rs +++ b/crates/aura-cli/src/project.rs @@ -622,6 +622,38 @@ mod tests { std::fs::remove_dir_all(&tmp).ok(); } + /// #245: a `[nodes]` pointer at a directory that does not exist refuses + /// with a clean message — it names the missing directory and keeps the + /// `[nodes]` pointer context, but does NOT leak the raw `cargo metadata` + /// toolchain error. That wrap is reserved for a directory that exists but + /// is not a valid crate; a plainly-absent directory should say exactly + /// that (`load` still refuses → CLI exit 1). + #[test] + fn a_missing_nodes_pointer_dir_refuses_without_the_cargo_metadata_leak() { + let tmp = std::env::temp_dir().join(format!("aura-missingptr-{}", std::process::id())); + std::fs::create_dir_all(&tmp).unwrap(); + // `missing-node-crate` is never created — the pointer target is absent. + std::fs::write( + tmp.join("Aura.toml"), + "[nodes]\ncrates = [\"missing-node-crate\"]\n", + ) + .unwrap(); + let e = load(&tmp, false).unwrap_err(); + let msg = e.to_string(); + // names the offending pointer path ... + assert!(msg.contains("missing-node-crate"), "names the pointer path: {msg}"); + // ... says plainly that the directory is not there ... + assert!(msg.contains("does not exist"), "states the directory is absent: {msg}"); + // ... keeps the [nodes] pointer context ... + assert!(msg.contains("[nodes]"), "keeps the pointer context: {msg}"); + // ... and does not leak the raw toolchain error for a simple absence. + assert!( + !msg.contains("cargo metadata"), + "no cargo-metadata leak for an absent directory: {msg}" + ); + std::fs::remove_dir_all(&tmp).ok(); + } + #[test] fn aura_toml_parses_empty_partial_and_unknown_keys() { let t: AuraToml = toml::from_str("").unwrap();