refactor(test-support): Use snapbox to look up binaries

This commit is contained in:
Ed Page 2022-04-18 16:14:46 -05:00
parent caca7f2b24
commit 5eaec4fa2f
3 changed files with 3 additions and 20 deletions

View File

@ -11,6 +11,7 @@ doctest = false
anyhow = "1.0.34"
cargo-test-macro = { path = "../cargo-test-macro" }
cargo-util = { path = "../cargo-util" }
snapbox = { version = "0.2.8", features = ["diff", "path"] }
filetime = "0.2"
flate2 = { version = "1.0", default-features = false, features = ["zlib"] }
git2 = "0.14.2"

View File

@ -470,24 +470,8 @@ pub fn main_file(println: &str, deps: &[&str]) -> String {
buf
}
// Path to cargo executables
pub fn cargo_dir() -> PathBuf {
env::var_os("CARGO_BIN_PATH")
.map(PathBuf::from)
.or_else(|| {
env::current_exe().ok().map(|mut path| {
path.pop();
if path.ends_with("deps") {
path.pop();
}
path
})
})
.unwrap_or_else(|| panic!("CARGO_BIN_PATH wasn't set. Cannot continue running test"))
}
pub fn cargo_exe() -> PathBuf {
cargo_dir().join(format!("cargo{}", env::consts::EXE_SUFFIX))
snapbox::cmd::cargo_bin("cargo")
}
/// This is the raw output from the process.

View File

@ -1,6 +1,4 @@
pub fn cargo_exe() -> &'static std::path::Path {
snapbox::cmd::cargo_bin!("cargo")
}
use cargo_test_support::cargo_exe;
pub fn cargo_command() -> snapbox::cmd::Command {
let mut cmd = snapbox::cmd::Command::new(cargo_exe()).with_assert(assert());