Skip to content

Use cargo_bin!() macro instead of deprecated cargo_bin fn in integration tests - #1229

Open
MsfPablo wants to merge 1 commit into
lsd-rs:mainfrom
MsfPablo:cargo-bin-macro-1178
Open

Use cargo_bin!() macro instead of deprecated cargo_bin fn in integration tests#1229
MsfPablo wants to merge 1 commit into
lsd-rs:mainfrom
MsfPablo:cargo-bin-macro-1178

Conversation

@MsfPablo

@MsfPablo MsfPablo commented Aug 8, 2026

Copy link
Copy Markdown

Closes #1178.

The integration-test helper cmd() used Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(), which relies on assert_cmd probing the target/ layout. As tracked in #1178, that path is fragile under non-default build directories (e.g. CARGO_BUILD_BUILD_DIR) and the cargo_bin function has been deprecated in favor of the cargo_bin! / cargo_bin_cmd! macros.

This switches the helper to:

fn cmd() -> Command {
    Command::new(assert_cmd::cargo_bin!())
}

cargo_bin!() resolves the binary through the official CARGO_BIN_EXE_lsd env var that Cargo sets for the package's own bin target, so it is robust to the build directory and no longer needs an .unwrap().

Dependency change

cargo_bin!() landed in assert_cmd 2.0.17, so this bumps the assert_cmd dev-dependency in the lockfile from 2.0.14 → 2.2.2. The Cargo.toml constraint stays at assert_cmd = "2" (no tightening); this is a lockfile-only update.

Verification

  • cargo build --tests — clean
  • cargo test — 42 passed; the only failure (test_date_custom_format_supports_nanos_with_length) is pre-existing and locale-dependent (%.3f emits a comma under LC_TIME=es_ES.UTF-8\)); it fails identically on clean mainand passes under theen_US`/C locale used in CI.
  • cargo fmt --check — clean
  • cargo clippy --all-targets — no new warnings (the remaining ones are pre-existing in src/display.rs)

The integration-test helper used Command::cargo_bin(name).unwrap(), which
relies on assert_cmd probing the target/ layout and has been deprecated in
favor of the cargo_bin!() / cargo_bin_cmd!() macros. cargo_bin!() resolves
the binary via the official CARGO_BIN_EXE_<name> env var set by Cargo, so it
is robust to non-default build directories (CARGO_BUILD_BUILD_DIR) and no
longer needs an unwrap().

Bumps the assert_cmd dev-dependency in the lockfile from 2.0.14 to 2.2.2
(the Cargo.toml constraint stays at "2"); the cargo_bin!() macro landed in
2.0.17.

Closes lsd-rs#1178
@MsfPablo
MsfPablo requested a review from zwpaper as a code owner August 8, 2026 20:33
@MsfPablo

Copy link
Copy Markdown
Author

Ping on this. It's a mechanical swap to the cargo_bin!() macro, so it should be quick to eyeball. Let me know if you'd rather fold it into a broader test cleanup instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tests rely on deprecated assert_cmd::cargo_bin which will break on future Cargo versions

1 participant