Skip to content

Commit 284e11d

Browse files
authored
Merge pull request #406 from epage/cargo_bin
fix: Deprecate cargo_bin (runtime version)
2 parents b12a31f + 04c74be commit 284e11d

File tree

3 files changed

+34
-25
lines changed

3 files changed

+34
-25
lines changed

crates/snapbox-macros/src/lib.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,6 @@ macro_rules! debug {
2929
($($arg:tt)*) => {};
3030
}
3131

32-
/// The absolute path to a binary target's executable.
33-
///
34-
/// The `bin_target_name` is the name of the binary
35-
/// target, exactly as-is.
36-
///
37-
/// **NOTE:** This is only set when building an integration test or benchmark.
38-
///
39-
/// ## Example
40-
///
41-
/// ```rust,no_run
42-
/// #[test]
43-
/// fn cli_tests() {
44-
/// trycmd::TestCases::new()
45-
/// .default_bin_path(trycmd::cargo_bin!("bin-fixture"))
46-
/// .case("tests/cmd/*.trycmd");
47-
/// }
48-
/// ```
49-
#[macro_export]
50-
macro_rules! cargo_bin {
51-
($bin_target_name:expr) => {
52-
::std::path::Path::new(env!(concat!("CARGO_BIN_EXE_", $bin_target_name)))
53-
};
54-
}
55-
5632
#[doc = include_str!("../README.md")]
5733
#[cfg(doctest)]
5834
pub struct ReadmeDoctests;

crates/snapbox/src/cmd.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,11 +845,16 @@ fn wait(
845845
child.wait()
846846
}
847847

848-
pub use snapbox_macros::cargo_bin;
848+
#[doc(inline)]
849+
pub use crate::cargo_bin;
849850

850851
/// Look up the path to a cargo-built binary within an integration test.
851852
///
852853
/// **NOTE:** Prefer [`cargo_bin!`] as this makes assumptions about cargo
854+
#[deprecated(
855+
since = "0.6.23",
856+
note = "incompatible with a custom cargo build-dir, see instead `cmd::cargo_bin!`"
857+
)]
853858
pub fn cargo_bin(name: &str) -> std::path::PathBuf {
854859
let file_name = format!("{}{}", name, std::env::consts::EXE_SUFFIX);
855860
let target_dir = target_dir();

crates/snapbox/src/macros.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,34 @@ macro_rules! fn_path {
108108
}};
109109
}
110110

111+
/// The absolute path to a binary target's executable.
112+
///
113+
/// The `bin_target_name` is the name of the binary
114+
/// target, exactly as-is.
115+
///
116+
/// **NOTE:** This is only set when building an integration test or benchmark.
117+
///
118+
/// ## Example
119+
///
120+
/// ```rust,no_run
121+
/// #[test]
122+
/// fn cli_tests() {
123+
/// trycmd::TestCases::new()
124+
/// .default_bin_path(trycmd::cargo_bin!("bin-fixture"))
125+
/// .case("tests/cmd/*.trycmd");
126+
/// }
127+
/// ```
128+
#[macro_export]
129+
#[doc(hidden)]
130+
macro_rules! cargo_bin {
131+
() => {
132+
$crate::cmd::cargo_bin!(env!("CARGO_PKG_NAME"))
133+
};
134+
($bin_target_name:expr) => {
135+
::std::path::Path::new(env!(concat!("CARGO_BIN_EXE_", $bin_target_name)))
136+
};
137+
}
138+
111139
#[cfg(test)]
112140
mod test {
113141
#[test]

0 commit comments

Comments
 (0)