From 6c75acfffcf63ca8df7a3e4b2808f64ceb13cdf2 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 8 Jan 2026 09:28:11 -0500 Subject: [PATCH 1/4] Replace deprecated cargo_bin with cargo_bin! macro The old Command::cargo_bin() is deprecated and will break when Cargo changes build directory layout. Updated to use cargo_bin!() macro instead. Bumped assert_cmd to 2.0.16 to get the new macro. Fixes #3528 --- Cargo.lock | 11 ++--------- Cargo.toml | 2 +- tests/tester/mod.rs | 13 ++----------- tests/utils/command.rs | 2 +- 4 files changed, 6 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 43f40e56..10607f7e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -83,13 +83,12 @@ checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" [[package]] name = "assert_cmd" -version = "2.0.16" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc1835b7f27878de8525dc71410b5a31cdcc5f230aed5ba5df968e09c201b23d" +checksum = "bcbb6924530aa9e0432442af08bbcafdad182db80d2e560da42a6d442535bf85" dependencies = [ "anstyle", "bstr", - "doc-comment", "libc", "predicates", "predicates-core", @@ -471,12 +470,6 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59f8e79d1fbf76bdfbde321e902714bf6c49df88a7dda6fc682fc2979226962d" -[[package]] -name = "doc-comment" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" - [[package]] name = "either" version = "1.13.0" diff --git a/Cargo.toml b/Cargo.toml index 757011d4..828520b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -95,7 +95,7 @@ features = ["wrap_help", "cargo"] plist = "1.7.0" [dev-dependencies] -assert_cmd = "2.0.12" +assert_cmd = "2.0.16" expect-test = "1.5.0" serial_test = { version = "2.0.0", default-features = false } predicates = "3.1.3" diff --git a/tests/tester/mod.rs b/tests/tester/mod.rs index 6c7e4226..42d88afd 100644 --- a/tests/tester/mod.rs +++ b/tests/tester/mod.rs @@ -52,17 +52,8 @@ impl BatTester { impl Default for BatTester { fn default() -> Self { let temp_dir = create_sample_directory().expect("sample directory"); - - let root = env::current_exe() - .expect("tests executable") - .parent() - .expect("tests executable directory") - .parent() - .expect("bat executable directory") - .to_path_buf(); - - let exe_name = if cfg!(windows) { "bat.exe" } else { "bat" }; - let exe = root.join(exe_name); + + let exe = assert_cmd::cargo::cargo_bin!("bat").to_path_buf(); BatTester { temp_dir, exe } } diff --git a/tests/utils/command.rs b/tests/utils/command.rs index 40b01960..3a077d66 100644 --- a/tests/utils/command.rs +++ b/tests/utils/command.rs @@ -4,7 +4,7 @@ use assert_cmd::cargo::CommandCargoExt; use std::process::Command; pub fn bat_raw_command_with_config() -> Command { - let mut cmd = Command::cargo_bin("bat").unwrap(); + let mut cmd = Command::new(assert_cmd::cargo::cargo_bin!("bat")); cmd.current_dir("tests/examples"); cmd.env_remove("BAT_CACHE_PATH"); cmd.env_remove("BAT_CONFIG_DIR"); From 0a97a1edd7d5d2262aa5a3646dda63fe0ce0a816 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 8 Jan 2026 09:35:01 -0500 Subject: [PATCH 2/4] Add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96d9edbc..b8c6493b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ## Bugfixes - `--help` now correctly honors `--pager=builtin`. See #3516 (@keith-hall) - `--help` now correctly honors custom themes. See #3524 (@keith-hall) +- Fixed test compatibility with future Cargo build directory changes, see #3528 (@nmacl) ## Other From 31f982e736cc8d1b39164c29126fbfcf545abf8d Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 8 Jan 2026 09:42:42 -0500 Subject: [PATCH 3/4] Fixed formatting --- tests/tester/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tester/mod.rs b/tests/tester/mod.rs index 42d88afd..b25a634c 100644 --- a/tests/tester/mod.rs +++ b/tests/tester/mod.rs @@ -52,7 +52,7 @@ impl BatTester { impl Default for BatTester { fn default() -> Self { let temp_dir = create_sample_directory().expect("sample directory"); - + let exe = assert_cmd::cargo::cargo_bin!("bat").to_path_buf(); BatTester { temp_dir, exe } From 57bf8ff7dac2f2830dda9bbe4d1225bc60e01509 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 8 Jan 2026 09:45:41 -0500 Subject: [PATCH 4/4] Update changelog with PR number --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8c6493b..02340944 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ ## Bugfixes - `--help` now correctly honors `--pager=builtin`. See #3516 (@keith-hall) - `--help` now correctly honors custom themes. See #3524 (@keith-hall) -- Fixed test compatibility with future Cargo build directory changes, see #3528 (@nmacl) +- Fixed test compatibility with future Cargo build directory changes, see #3550 (@nmacl) ## Other