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.
This commit is contained in:
parent
56ece480ee
commit
119445ce6c
|
|
@ -410,14 +410,6 @@ impl TestFormula {
|
||||||
|
|
||||||
// For each command.
|
// For each command.
|
||||||
for (i, assertion) in test.assertions.iter().enumerate() {
|
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
|
let location = assertion
|
||||||
.path
|
.path
|
||||||
.file_name()
|
.file_name()
|
||||||
|
|
@ -447,6 +439,14 @@ impl TestFormula {
|
||||||
continue;
|
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() {
|
if !run.path().exists() {
|
||||||
log::warn!(target: "test", "{location}: Directory {} does not exist. Creating..", run.path().display());
|
log::warn!(target: "test", "{location}: Directory {} does not exist. Creating..", run.path().display());
|
||||||
fs::create_dir_all(run.path())?;
|
fs::create_dir_all(run.path())?;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue