cli-test: Remove special handling for `rad`
The special handling for `rad` was introduced in commit `e63f33489055962845c70976bd9a40d0d84c6b1c` without further comment. Since we control the `$PATH` for spawning `rad`, and it is clear that `rad` must be on the path, we do not need any special handing. See also: - https://doc.rust-lang.org/std/process/struct.Command.html#method.new - https://github.com/rust-lang/rust/issues/15149 - https://github.com/rust-lang/rust/issues/37519
This commit is contained in:
parent
3cd1af1dd5
commit
56ece480ee
|
|
@ -417,6 +417,7 @@ impl TestFormula {
|
|||
*arg = arg.replace(format!("${k}").as_str(), &v);
|
||||
}
|
||||
}
|
||||
|
||||
let location = assertion
|
||||
.path
|
||||
.file_name()
|
||||
|
|
@ -425,9 +426,7 @@ impl TestFormula {
|
|||
.map(|f| f + ":" + assertion.line.to_string().as_str())
|
||||
.unwrap_or(String::from("<none>"));
|
||||
|
||||
let (cmd, cmd_display) = if assertion.command == "rad" {
|
||||
(snapbox::cmd::cargo_bin("rad"), "rad".to_string())
|
||||
} else if assertion.command == "cd" {
|
||||
if assertion.command == "cd" {
|
||||
let arg = assertion.args.first().unwrap();
|
||||
let dir: PathBuf = arg.into();
|
||||
let dir = run.path().join(dir);
|
||||
|
|
@ -446,9 +445,7 @@ impl TestFormula {
|
|||
run.cd(dir);
|
||||
|
||||
continue;
|
||||
} else {
|
||||
(PathBuf::from(&assertion.command), assertion.command.clone())
|
||||
};
|
||||
}
|
||||
|
||||
if !run.path().exists() {
|
||||
log::warn!(target: "test", "{location}: Directory {} does not exist. Creating..", run.path().display());
|
||||
|
|
@ -467,7 +464,7 @@ impl TestFormula {
|
|||
|
||||
let bins = std::env::join_paths(bins(self.cwd.clone())).unwrap();
|
||||
|
||||
let command = Command::new(cmd.clone())
|
||||
let command = Command::new(assertion.command.clone())
|
||||
.env_clear()
|
||||
.env("PATH", &bins)
|
||||
.env("RUST_BACKTRACE", "1")
|
||||
|
|
@ -477,7 +474,7 @@ impl TestFormula {
|
|||
.args(args.clone())
|
||||
.with_assert(assert.clone());
|
||||
|
||||
log::debug!(target: "test", "{location}: `{} {}` @ {}", cmd_display, args.join(" "), run.path().display());
|
||||
log::debug!(target: "test", "{location}: `{} {}` @ {}", assertion.command, args.join(" "), run.path().display());
|
||||
log::trace!(target: "test", "{location}: {}", run.envs().map(|(k, v)| format!("{}={}", k, v)).collect::<Vec<_>>().join(", "));
|
||||
log::logger().flush();
|
||||
|
||||
|
|
@ -515,11 +512,11 @@ impl TestFormula {
|
|||
}
|
||||
Err(err) => {
|
||||
if err.kind() == io::ErrorKind::NotFound {
|
||||
log::error!(target: "test", "{location}: Command `{}` does not exist..", cmd.display());
|
||||
log::error!(target: "test", "{location}: Command `{}` does not exist..", assertion.command);
|
||||
}
|
||||
return Err(io::Error::new(
|
||||
err.kind(),
|
||||
format!("{location}: {err}: `{}`", cmd.display()),
|
||||
format!("{location}: {err}: `{}`", assertion.command),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue