Skip to content

Commit e60035f

Browse files
committed
docs: Prefer pkg_name over CARGO_PKG_NAME
1 parent 069482b commit e60035f

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/cargo.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
//!
1010
//! ```rust,no_run
1111
//! use assert_cmd::prelude::*;
12+
//! use assert_cmd::pkg_name;
1213
//!
1314
//! use std::process::Command;
1415
//!
15-
//! let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME"))
16+
//! let mut cmd = Command::cargo_bin(pkg_name!())
1617
//! .unwrap();
1718
//! let output = cmd.unwrap();
1819
//! ```
@@ -74,10 +75,11 @@ pub use crate::cargo_bin;
7475
///
7576
/// ```rust,no_run
7677
/// use assert_cmd::prelude::*;
78+
/// use assert_cmd::pkg_name;
7779
///
7880
/// use std::process::Command;
7981
///
80-
/// let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME"))
82+
/// let mut cmd = Command::cargo_bin(pkg_name!())
8183
/// .unwrap();
8284
/// let output = cmd.unwrap();
8385
/// println!("{:?}", output);
@@ -104,10 +106,11 @@ where
104106
///
105107
/// ```rust,no_run
106108
/// use assert_cmd::prelude::*;
109+
/// use assert_cmd::pkg_name;
107110
///
108111
/// use std::process::Command;
109112
///
110-
/// let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME"))
113+
/// let mut cmd = Command::cargo_bin(pkg_name!())
111114
/// .unwrap();
112115
/// let output = cmd.unwrap();
113116
/// println!("{:?}", output);

src/cmd.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ impl Command {
4343
///
4444
/// ```rust,no_run
4545
/// use assert_cmd::Command;
46+
/// use assert_cmd::pkg_name;
4647
///
47-
/// let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME"))
48+
/// let mut cmd = Command::cargo_bin(pkg_name!())
4849
/// .unwrap();
4950
/// let output = cmd.unwrap();
5051
/// println!("{:?}", output);

tests/cargo.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::process::Command;
22

3+
use assert_cmd::pkg_name;
34
use assert_cmd::prelude::*;
45
use escargot::CURRENT_TARGET;
56

@@ -41,15 +42,15 @@ fn mod_example() {
4142
#[test]
4243
#[should_panic] // No bin named `assert_cmd
4344
fn trait_example() {
44-
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap();
45+
let mut cmd = Command::cargo_bin(pkg_name!()).unwrap();
4546
let output = cmd.unwrap();
4647
println!("{output:?}");
4748
}
4849

4950
#[test]
5051
#[should_panic] // No bin named `assert_cmd
5152
fn cargo_bin_example_1() {
52-
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap();
53+
let mut cmd = Command::cargo_bin(pkg_name!()).unwrap();
5354
let output = cmd.unwrap();
5455
println!("{output:?}");
5556
}

0 commit comments

Comments
 (0)