File tree 3 files changed +34
-0
lines changed
3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,9 @@ use std::fmt;
60
60
use std:: path;
61
61
use std:: process;
62
62
63
+ #[ doc( inline) ]
64
+ pub use crate :: cargo_bin;
65
+
63
66
/// Create a [`Command`] for a `bin` in the Cargo project.
64
67
///
65
68
/// `CommandCargoExt` is an extension trait for [`Command`][std::process::Command] to easily launch a crate's
95
98
/// this method with [cross](https://github.com/cross-rs/cross), no extra configuration is
96
99
/// needed.
97
100
///
101
+ /// **NOTE:** Prefer [`cargo_bin!`] as this makes assumptions about cargo
102
+ ///
98
103
/// # Examples
99
104
///
100
105
/// ```rust,no_run
@@ -217,6 +222,8 @@ fn target_dir() -> path::PathBuf {
217
222
}
218
223
219
224
/// Look up the path to a cargo-built binary within an integration test.
225
+ ///
226
+ /// **NOTE:** Prefer [`cargo_bin!`] as this makes assumptions about cargo
220
227
pub fn cargo_bin < S : AsRef < str > > ( name : S ) -> path:: PathBuf {
221
228
cargo_bin_str ( name. as_ref ( ) )
222
229
}
Original file line number Diff line number Diff line change @@ -37,6 +37,8 @@ impl Command {
37
37
///
38
38
/// See the [`cargo` module documentation][crate::cargo] for caveats and workarounds.
39
39
///
40
+ /// **NOTE:** Prefer [`cargo_bin!`][crate::cargo::cargo_bin!] as this makes assumptions about cargo
41
+ ///
40
42
/// # Examples
41
43
///
42
44
/// ```rust,no_run
Original file line number Diff line number Diff line change @@ -23,3 +23,28 @@ macro_rules! crate_name {
23
23
env!( "CARGO_PKG_NAME" )
24
24
} ;
25
25
}
26
+
27
+ /// The absolute path to a binary target's executable.
28
+ ///
29
+ /// The `bin_target_name` is the name of the binary
30
+ /// target, exactly as-is.
31
+ ///
32
+ /// **NOTE:** This is only set when building an integration test or benchmark.
33
+ ///
34
+ /// ## Example
35
+ ///
36
+ /// ```rust,no_run
37
+ /// #[test]
38
+ /// fn cli_tests() {
39
+ /// trycmd::TestCases::new()
40
+ /// .default_bin_path(trycmd::cargo_bin!("bin-fixture"))
41
+ /// .case("tests/cmd/*.trycmd");
42
+ /// }
43
+ /// ```
44
+ #[ macro_export]
45
+ #[ doc( hidden) ]
46
+ macro_rules! cargo_bin {
47
+ ( $bin_target_name: expr) => {
48
+ :: std:: path:: Path :: new( env!( concat!( "CARGO_BIN_EXE_" , $bin_target_name) ) )
49
+ } ;
50
+ }
You can’t perform that action at this time.
0 commit comments