cli-test: Configure `escargot` properly
Configuration calls to `escargot` were removed in commit `4894657b`. An unintentional consequence are spurious failures to invoke freshly compiled binaries in CLI tests. Bring back the explicit configuration to remedy.
This commit is contained in:
parent
5aca9bf16a
commit
3cd1af1dd5
|
|
@ -10,6 +10,10 @@ use snapbox::cmd::{Command, OutputAssert};
|
||||||
use snapbox::{Assert, Substitutions};
|
use snapbox::{Assert, Substitutions};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
|
const CARGO_TARGET_DIR_DIRNAME: &str = "target";
|
||||||
|
|
||||||
|
const CARGO_PROFILE: &str = "debug";
|
||||||
|
|
||||||
/// Used to ensure the build task is only run once.
|
/// Used to ensure the build task is only run once.
|
||||||
static BUILD: sync::Once = sync::Once::new();
|
static BUILD: sync::Once = sync::Once::new();
|
||||||
|
|
||||||
|
|
@ -195,9 +199,13 @@ impl TestFormula {
|
||||||
for (package, binary) in binaries {
|
for (package, binary) in binaries {
|
||||||
log::debug!(target: "test", "Building binaries for package `{package}`..");
|
log::debug!(target: "test", "Building binaries for package `{package}`..");
|
||||||
|
|
||||||
|
let cargo_manifest_dir = cargo_manifest_dir();
|
||||||
|
|
||||||
let results = escargot::CargoBuild::new()
|
let results = escargot::CargoBuild::new()
|
||||||
.package(package)
|
.package(package)
|
||||||
.bin(binary)
|
.bin(binary)
|
||||||
|
.manifest_path(cargo_manifest_dir.clone().join("Cargo.toml"))
|
||||||
|
.target_dir(cargo_manifest_dir.join(CARGO_TARGET_DIR_DIRNAME))
|
||||||
.exec()
|
.exec()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|
@ -522,6 +530,10 @@ impl TestFormula {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn cargo_manifest_dir() -> PathBuf {
|
||||||
|
env::var("CARGO_MANIFEST_DIR").map(PathBuf::from).unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the list of binary paths to use as `$PATH` for the tests,
|
/// Get the list of binary paths to use as `$PATH` for the tests,
|
||||||
/// starting with the current working directory.
|
/// starting with the current working directory.
|
||||||
fn bins(cwd: PathBuf) -> Vec<PathBuf> {
|
fn bins(cwd: PathBuf) -> Vec<PathBuf> {
|
||||||
|
|
@ -531,18 +543,11 @@ fn bins(cwd: PathBuf) -> Vec<PathBuf> {
|
||||||
// this makes it more convenient to execute scripts during testing.
|
// this makes it more convenient to execute scripts during testing.
|
||||||
bins.push(cwd);
|
bins.push(cwd);
|
||||||
|
|
||||||
if let Ok(manifest_dir) = env::var("CARGO_MANIFEST_DIR") {
|
bins.push(
|
||||||
let profile = cfg!(debug_assertions)
|
cargo_manifest_dir()
|
||||||
.then_some("debug")
|
.join(CARGO_TARGET_DIR_DIRNAME)
|
||||||
.unwrap_or("release");
|
.join(CARGO_PROFILE),
|
||||||
let target_dir = env::var("CARGO_TARGET_DIR").unwrap_or("target".to_string());
|
);
|
||||||
|
|
||||||
bins.push(
|
|
||||||
PathBuf::from(manifest_dir.as_str())
|
|
||||||
.join(&target_dir)
|
|
||||||
.join(profile),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the "real" `$PATH`.
|
// Add the "real" `$PATH`.
|
||||||
if let Ok(path) = env::var("PATH") {
|
if let Ok(path) = env::var("PATH") {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue