Skip to content

Commit 53f3fa2

Browse files
fix(tests): Use cargo_bin macro for binary discovery in tests
Use the `cargo_bin!` macro from assert_cmd to locate the sentry-cli binary. This reads the `CARGO_BIN_EXE_sentry-cli` environment variable set by Cargo at compile time, making tests work regardless of custom `build-dir` settings in cargo config. Previously, both `Command::cargo_bin()` and trycmd's internal binary discovery would fail when a custom build directory was configured, causing tests to either error or silently pass as "ignored". Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e0b0c69 commit 53f3fa2

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

tests/integration/test_utils/test_manager.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::ffi::OsStr;
22
use std::fmt::Display;
33

4+
use assert_cmd::cargo::cargo_bin;
45
use assert_cmd::Command;
56
use mockito::{Mock, Server, ServerGuard};
67
use thiserror::Error;
@@ -163,6 +164,7 @@ impl TrycmdTestManager {
163164

164165
fn new(manager: TestManager, path: impl Display) -> Self {
165166
let test_case = TestCases::new();
167+
test_case.register_bin("sentry-cli", cargo_bin!("sentry-cli"));
166168

167169
env::set(manager.server_info(), |k, v| {
168170
test_case.env(k, v);
@@ -228,7 +230,7 @@ impl AssertCmdTestManager {
228230
I: IntoIterator<Item = S>,
229231
S: AsRef<OsStr>,
230232
{
231-
let mut command = Command::cargo_bin("sentry-cli").expect("sentry-cli should be available");
233+
let mut command = Command::new(cargo_bin!("sentry-cli"));
232234
command.args(args);
233235

234236
env::set(manager.server_info(), |k, v| {

0 commit comments

Comments
 (0)