From 119445ce6c9be26a3fae1b0e06f34292c5806cd5 Mon Sep 17 00:00:00 2001 From: Lorenz Leutgeb Date: Mon, 16 Feb 2026 20:23:50 +0100 Subject: [PATCH] cli-test: Move `let mut args` closer to its uses In case a `cd` command is to be processed, no replacement of environment variables in arguments is performed. This means that the definition of `let mut args` and the replacement itself can be moved closer to where `args` is then actually used, which is easier to reason about. --- crates/radicle-cli-test/src/lib.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/radicle-cli-test/src/lib.rs b/crates/radicle-cli-test/src/lib.rs index 281c10ea..549de7d6 100644 --- a/crates/radicle-cli-test/src/lib.rs +++ b/crates/radicle-cli-test/src/lib.rs @@ -410,14 +410,6 @@ impl TestFormula { // For each command. for (i, assertion) in test.assertions.iter().enumerate() { - // Expand environment variables. - let mut args = assertion.args.clone(); - for arg in &mut args { - for (k, v) in run.envs() { - *arg = arg.replace(format!("${k}").as_str(), &v); - } - } - let location = assertion .path .file_name() @@ -447,6 +439,14 @@ impl TestFormula { continue; } + // Expand environment variables. + let mut args = assertion.args.clone(); + for arg in &mut args { + for (k, v) in run.envs() { + *arg = arg.replace(format!("${k}").as_str(), &v); + } + } + if !run.path().exists() { log::warn!(target: "test", "{location}: Directory {} does not exist. Creating..", run.path().display()); fs::create_dir_all(run.path())?;