20
20
//! .unwrap();
21
21
//! ```
22
22
//!
23
- //! Caching the binary's location:
23
+ //! For caching to minimize cargo overhead or customize the build process, see [`escargot`].
24
24
//!
25
- //! ```rust
25
+ //! ```rust,ignore
26
26
//! use assert_cmd::prelude::*;
27
+ //! use escargot;
27
28
//!
28
29
//! use std::process::Command;
29
30
//!
30
- //! let bin_under_test = assert_cmd::cargo::main_binary_path().unwrap();
31
- //! Command::new(&bin_under_test)
31
+ //! let bin_under_test = escargot::CargoBuild::new()
32
+ //! .bin("bin_fixture")
33
+ //! .current_release()
34
+ //! .current_target()
35
+ //! .run()
36
+ //! .unwrap();
37
+ //! bin_under_test.command()
32
38
//! .unwrap();
33
39
//! ```
34
40
//!
37
43
//! [`lazy_static`]: https://crates.io/crates/lazy_static
38
44
//! [`CommandCargoExt`]: trait.CommandCargoExt.html
39
45
//! [`Command`]: https://doc.rust-lang.org/std/process/struct.Command.html
46
+ //! [`escargot`]: https://docs.rs/escargot/
40
47
41
48
use std:: error:: Error ;
42
49
use std:: ffi;
@@ -128,18 +135,29 @@ where
128
135
129
136
impl CommandCargoExt for process:: Command {
130
137
fn main_binary ( ) -> Result < Self , CargoError > {
131
- let cmd = main_binary_path ( ) ?;
132
- Ok ( process:: Command :: new ( & cmd) )
138
+ let runner = escargot:: CargoBuild :: new ( )
139
+ . current_release ( )
140
+ . run ( )
141
+ . map_err ( CargoError :: with_cause) ?;
142
+ Ok ( runner. command ( ) )
133
143
}
134
144
135
145
fn cargo_bin < S : AsRef < ffi:: OsStr > > ( name : S ) -> Result < Self , CargoError > {
136
- let cmd = cargo_bin_path ( name) ?;
137
- Ok ( process:: Command :: new ( & cmd) )
146
+ let runner = escargot:: CargoBuild :: new ( )
147
+ . bin ( name)
148
+ . current_release ( )
149
+ . run ( )
150
+ . map_err ( CargoError :: with_cause) ?;
151
+ Ok ( runner. command ( ) )
138
152
}
139
153
140
154
fn cargo_example < S : AsRef < ffi:: OsStr > > ( name : S ) -> Result < Self , CargoError > {
141
- let cmd = cargo_example_path ( name) ?;
142
- Ok ( process:: Command :: new ( & cmd) )
155
+ let runner = escargot:: CargoBuild :: new ( )
156
+ . example ( name)
157
+ . current_release ( )
158
+ . run ( )
159
+ . map_err ( CargoError :: with_cause) ?;
160
+ Ok ( runner. command ( ) )
143
161
}
144
162
}
145
163
@@ -160,9 +178,9 @@ impl CommandCargoExt for process::Command {
160
178
/// Command::new(&bin_under_test)
161
179
/// .unwrap();
162
180
/// ```
181
+ #[ deprecated( since = "0.9.1" , note = "For caching, using escargot directly." ) ]
163
182
pub fn main_binary_path ( ) -> Result < path:: PathBuf , CargoError > {
164
- let runner = escargot:: Cargo :: new ( )
165
- . build ( )
183
+ let runner = escargot:: CargoBuild :: new ( )
166
184
. current_release ( )
167
185
. run ( )
168
186
. map_err ( CargoError :: with_cause) ?;
@@ -184,9 +202,9 @@ pub fn main_binary_path() -> Result<path::PathBuf, CargoError> {
184
202
/// Command::new(&bin_under_test)
185
203
/// .unwrap();
186
204
/// ```
205
+ #[ deprecated( since = "0.9.1" , note = "For caching, using escargot directly." ) ]
187
206
pub fn cargo_bin_path < S : AsRef < ffi:: OsStr > > ( name : S ) -> Result < path:: PathBuf , CargoError > {
188
- let runner = escargot:: Cargo :: new ( )
189
- . build ( )
207
+ let runner = escargot:: CargoBuild :: new ( )
190
208
. bin ( name)
191
209
. current_release ( )
192
210
. run ( )
@@ -209,9 +227,9 @@ pub fn cargo_bin_path<S: AsRef<ffi::OsStr>>(name: S) -> Result<path::PathBuf, Ca
209
227
/// Command::new(&bin_under_test)
210
228
/// .unwrap();
211
229
/// ```
230
+ #[ deprecated( since = "0.9.1" , note = "For caching, using escargot directly." ) ]
212
231
pub fn cargo_example_path < S : AsRef < ffi:: OsStr > > ( name : S ) -> Result < path:: PathBuf , CargoError > {
213
- let runner = escargot:: Cargo :: new ( )
214
- . build ( )
232
+ let runner = escargot:: CargoBuild :: new ( )
215
233
. example ( name)
216
234
. current_release ( )
217
235
. run ( )
0 commit comments