From e598a580122d7f60873a54b2e2a00e0fb7a011a6 Mon Sep 17 00:00:00 2001 From: Ralf Anton Beier Date: Wed, 5 Aug 2026 08:06:32 +0200 Subject: [PATCH] =?UTF-8?q?fix(test):=20locate=20the=20synth=20binary=20vi?= =?UTF-8?q?a=20CARGO=5FBIN=5FEXE=20=E2=80=94=20un-red=20`Code=20Coverage`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `Code Coverage` has been RED repo-wide — on main and on every open PR — for a reason unrelated to coverage. Two CLI tests hand-rolled their binary path: two `.parent()` hops up from `current_exe()`, then push "synth". That resolves for the plain `target/debug/deps/` layout and for nothing else. Under `cargo llvm-cov` the test binary lives at target/llvm-cov-target/debug/build/synth-cli//out/ so the walk produced `...//synth` — a path that does not exist — and the tests failed on a MISSING BINARY rather than on anything they assert: 2 in async_intrinsics_gate.rs and ~56 in wast_compile.rs. The required `Test` job runs the plain layout and stayed green throughout, so a real gate sat red for a reason nobody read — the same "the checker is the defect" class as the vacuous gates and the correlated validators elsewhere in this release. Both now use `env!("CARGO_BIN_EXE_synth")`, which Cargo sets at compile time to the built binary's real path and is therefore layout-independent by construction — the mechanism every other CLI integration test already used. wast_compile.rs's comment even said "cargo sets this for integration tests", which is true of CARGO_BIN_EXE_synth and not of the walk beneath it. Swept: zero code-level `current_exe()` binary walks remain under crates/*/tests/, so this closes the class rather than the reported instance. Verified in the EXACT failing configuration, not a proxy: cargo llvm-cov --no-report --tests -p synth-cli \ --test wast_compile --test async_intrinsics_gate -> 56 passed, 2 passed, 2 passed; 0 failed plus the plain layout and a relocated CARGO_TARGET_DIR. `cargo fmt --check` clean. No production code touched. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01YJK5LZZEkV5smCY1jKn18L --- .../synth-cli/tests/async_intrinsics_gate.rs | 24 ++++++++++++------- crates/synth-cli/tests/wast_compile.rs | 22 +++++++++-------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/crates/synth-cli/tests/async_intrinsics_gate.rs b/crates/synth-cli/tests/async_intrinsics_gate.rs index 809b889e..5ff7ac28 100644 --- a/crates/synth-cli/tests/async_intrinsics_gate.rs +++ b/crates/synth-cli/tests/async_intrinsics_gate.rs @@ -16,16 +16,22 @@ use std::path::{Path, PathBuf}; use std::process::Command; +/// Locate the `synth` binary the way every other CLI test does. +/// +/// This used to walk two parents up from `current_exe()` and append `synth`, +/// which happens to be right for the plain `target/debug/deps/` layout and +/// WRONG for any other. Under `cargo llvm-cov` the test binary lives at +/// `target/llvm-cov-target/debug/build/synth-cli//out/`, so the walk +/// produced `…//synth` — a path that does not exist — and BOTH tests in +/// this file failed for a missing binary rather than for anything they assert. +/// That kept `Code Coverage` red repo-wide while the required `Test` job (plain +/// layout) stayed green: a real gate, failing for a reason unrelated to the code. +/// +/// `CARGO_BIN_EXE_` is set by Cargo at compile time to the actual path of +/// the built binary, so it is correct under every target-dir layout. Same +/// mechanism as the other CLI integration tests in this directory. fn synth_binary() -> PathBuf { - let mut path = std::env::current_exe() - .unwrap() - .parent() - .unwrap() - .parent() - .unwrap() - .to_path_buf(); - path.push("synth"); - path + PathBuf::from(env!("CARGO_BIN_EXE_synth")) } fn workspace_root() -> PathBuf { diff --git a/crates/synth-cli/tests/wast_compile.rs b/crates/synth-cli/tests/wast_compile.rs index c0c3df42..20ed0336 100644 --- a/crates/synth-cli/tests/wast_compile.rs +++ b/crates/synth-cli/tests/wast_compile.rs @@ -6,17 +6,19 @@ use std::path::{Path, PathBuf}; use std::process::Command; +/// Locate the `synth` binary. See the identical note in +/// `async_intrinsics_gate.rs`: walking up from `current_exe()` only works for +/// the plain `target/debug/deps/` layout, and silently produces a +/// nonexistent path under `cargo llvm-cov` (where the test binary lives at +/// `target/llvm-cov-target/debug/build/synth-cli//out/`). Every +/// test in this file then failed on a MISSING BINARY rather than on what it +/// asserts, which is why `Code Coverage` was red repo-wide while the required +/// `Test` job — same assertions, plain layout — stayed green. +/// +/// `CARGO_BIN_EXE_` is the thing Cargo actually sets for integration +/// tests, and it is layout-independent by construction. fn synth_binary() -> PathBuf { - // cargo sets this for integration tests - let mut path = std::env::current_exe() - .unwrap() - .parent() - .unwrap() - .parent() - .unwrap() - .to_path_buf(); - path.push("synth"); - path + PathBuf::from(env!("CARGO_BIN_EXE_synth")) } fn workspace_root() -> PathBuf {