pub struct CargoRun { /* private fields */ }Expand description
The run subcommand (emulated).
Created via CargoBuild::run.
Benefits over spawning cargo run:
- Able to cache binary path, avoiding cargo overhead.
- Independent of CWD.
- stdout/stderr are clean of
cargo runoutput.
Relevant features
printfor logged output to be printed instead, generally for test writing.
§Example
To create a CargoRun:
let run = escargot::CargoBuild::new()
.bin("bin")
.current_release()
.current_target()
.manifest_path("tests/testsuite/fixtures/bin/Cargo.toml")
.target_dir(target_dir.path())
.run()
.unwrap();
println!("artifact={}", run.path().display());See CargoRun::path for how to then run the newly compiled
program.
Implementations§
Source§impl CargoRun
impl CargoRun
Sourcepub fn path(&self) -> &Path
pub fn path(&self) -> &Path
Path to the specified binary.
This is to support alternative ways of launching the binary besides Command.
§Example
let run = escargot::CargoBuild::new()
.bin("bin")
.current_release()
.current_target()
.manifest_path("tests/testsuite/fixtures/bin/Cargo.toml")
.target_dir(target_dir.path())
.run()
.unwrap();
println!("artifact={}", run.path().display());or
let run = escargot::CargoBuild::new()
.example("example_fixture")
.current_release()
.current_target()
.manifest_path("tests/testsuite/fixtures/example/Cargo.toml")
.target_dir(target_dir.path())
.run()
.unwrap();
println!("artifact={}", run.path().display());Sourcepub fn command(&self) -> Command
pub fn command(&self) -> Command
Run the build artifact.
§Example
let run = escargot::CargoBuild::new()
.bin("bin")
.current_release()
.current_target()
.manifest_path("tests/testsuite/fixtures/bin/Cargo.toml")
.target_dir(target_dir.path())
.run()
.unwrap()
.command()
.arg("--help")
.status()
.unwrap();or
let run = escargot::CargoBuild::new()
.example("example_fixture")
.current_release()
.current_target()
.manifest_path("tests/testsuite/fixtures/example/Cargo.toml")
.target_dir(target_dir.path())
.run()
.unwrap()
.command()
.arg("--help")
.status()
.unwrap();Trait Implementations§
Auto Trait Implementations§
impl Freeze for CargoRun
impl RefUnwindSafe for CargoRun
impl Send for CargoRun
impl Sync for CargoRun
impl Unpin for CargoRun
impl UnwindSafe for CargoRun
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more