Find the device tests' compile worker above the test binary in any Cargo layout
The nightly's Cargo builds with its newer build-directory layout: a test binary now sits in target/<profile>/build/<package>/<hash>/out/, not target/<profile>/deps/, while the package's binaries are still copied up into target/<profile>/. compile_worker() took the test binary's grandparent, which now names build/metal2vulkan-validation/<hash>/corpus-pipeline, a file that does not exist, so every device test compiling through the worker would panic. It now takes the first corpus-pipeline above the test binary, which is target/<profile>/corpus-pipeline in either layout. reims-vgpu found the layout change in its own C API tests. Verified on the M3 Max (--cfg m2v_gpu, MoltenVK, under the Mac GPU lock): candidate::tests::engine_compute::a_store_runs_through_the_binder_under_the_validation_layer passes; the old formula's path is absent from the built target.
This commit is contained in:
1 parent
7d14d60cad
commit
bc05f43aa0
1 file changed
+19
-15
@@ -38,7 +38,7 @@ pub(crate) mod engine_render;
|
||||
mod pipeline_contracts;
|
||||
|
||||
/// The compile worker the device tests compile through: `corpus-pipeline`, the validation binary
|
||||
/// built beside this test binary, which serves the worker under the counting allocator, so each
|
||||
/// in this test binary's target profile directory, which serves the worker under the counting allocator, so each
|
||||
/// test pipeline compiles under the 20-s and 500-MiB boundary in a killable child, never in the
|
||||
/// process that holds the Vulkan device. It is executed once first: the OS may scan a freshly
|
||||
/// linked binary on its first exec (seconds on macOS), which the worker's deadline would count.
|
||||
@@ -49,20 +49,24 @@ pub(crate) fn compile_worker() -> &'static crate::worker::compile::CompileWorker
|
||||
static WORKER: std::sync::OnceLock<crate::worker::compile::CompileWorker> =
|
||||
std::sync::OnceLock::new();
|
||||
WORKER.get_or_init(|| {
|
||||
let program = std::env::current_exe()
|
||||
.ok()
|
||||
.and_then(|test| {
|
||||
// `target/<profile>/deps/<test>` beside `target/<profile>/corpus-pipeline`.
|
||||
let binary = format!("corpus-pipeline{}", std::env::consts::EXE_SUFFIX);
|
||||
Some(test.parent()?.parent()?.join(binary))
|
||||
})
|
||||
.expect("resolve the test binary's target directory");
|
||||
assert!(
|
||||
program.is_file(),
|
||||
"the compile worker {} is not built: run the package's tests without --lib, or build \
|
||||
its binaries with the same RUSTFLAGS (cargo build -p metal2vulkan-validation --bins)",
|
||||
program.display()
|
||||
);
|
||||
let binary = format!("corpus-pipeline{}", std::env::consts::EXE_SUFFIX);
|
||||
let test = std::env::current_exe().expect("the test binary's path");
|
||||
// The package's binaries are in `target/<profile>/`, above the test binary wherever
|
||||
// Cargo's layout puts it: `<profile>/deps/<test>`, or, in its newer build-directory
|
||||
// layout, `<profile>/build/<package>/<hash>/out/<test>`.
|
||||
let program = test
|
||||
.ancestors()
|
||||
.skip(1)
|
||||
.map(|directory| directory.join(&binary))
|
||||
.find(|path| path.is_file())
|
||||
.unwrap_or_else(|| {
|
||||
panic!(
|
||||
"the compile worker {binary} is not built above {}: run the package's tests \
|
||||
without --lib, or build its binaries with the same RUSTFLAGS \
|
||||
(cargo build -p metal2vulkan-validation --bins)",
|
||||
test.display()
|
||||
)
|
||||
});
|
||||
let _ = std::process::Command::new(&program)
|
||||
.arg("--help")
|
||||
.stdout(std::process::Stdio::null())
|
||||
|
||||
Reference in new issue
Block a user