Skip to content

Commit 119445c

Browse files
committed
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.
1 parent 56ece48 commit 119445c

File tree

1 file changed

+8
-8
lines changed
  • crates/radicle-cli-test/src

1 file changed

+8
-8
lines changed

crates/radicle-cli-test/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -410,14 +410,6 @@ impl TestFormula {
410410

411411
// For each command.
412412
for (i, assertion) in test.assertions.iter().enumerate() {
413-
// Expand environment variables.
414-
let mut args = assertion.args.clone();
415-
for arg in &mut args {
416-
for (k, v) in run.envs() {
417-
*arg = arg.replace(format!("${k}").as_str(), &v);
418-
}
419-
}
420-
421413
let location = assertion
422414
.path
423415
.file_name()
@@ -447,6 +439,14 @@ impl TestFormula {
447439
continue;
448440
}
449441

442+
// Expand environment variables.
443+
let mut args = assertion.args.clone();
444+
for arg in &mut args {
445+
for (k, v) in run.envs() {
446+
*arg = arg.replace(format!("${k}").as_str(), &v);
447+
}
448+
}
449+
450450
if !run.path().exists() {
451451
log::warn!(target: "test", "{location}: Directory {} does not exist. Creating..", run.path().display());
452452
fs::create_dir_all(run.path())?;

0 commit comments

Comments
 (0)