pub struct Execs {Show 16 fields
pub(crate) ran: bool,
pub(crate) process_builder: Option<ProcessBuilder>,
pub(crate) expect_stdin: Option<String>,
pub(crate) expect_exit_code: Option<i32>,
pub(crate) expect_stdout_data: Option<Data>,
pub(crate) expect_stderr_data: Option<Data>,
pub(crate) expect_stdout_contains: Vec<String>,
pub(crate) expect_stderr_contains: Vec<String>,
pub(crate) expect_stdout_contains_n: Vec<(String, usize)>,
pub(crate) expect_stdout_not_contains: Vec<String>,
pub(crate) expect_stderr_not_contains: Vec<String>,
pub(crate) expect_stdout_unordered: Vec<String>,
pub(crate) expect_stderr_unordered: Vec<String>,
pub(crate) expect_stderr_with_without: Vec<(Vec<String>, Vec<String>)>,
pub(crate) stream_output: bool,
pub(crate) assert: Assert,
}
Expand description
Fields§
§ran: bool
§process_builder: Option<ProcessBuilder>
§expect_stdin: Option<String>
§expect_exit_code: Option<i32>
§expect_stdout_data: Option<Data>
§expect_stderr_data: Option<Data>
§expect_stdout_contains: Vec<String>
§expect_stderr_contains: Vec<String>
§expect_stdout_contains_n: Vec<(String, usize)>
§expect_stdout_not_contains: Vec<String>
§expect_stderr_not_contains: Vec<String>
§expect_stdout_unordered: Vec<String>
§expect_stderr_unordered: Vec<String>
§expect_stderr_with_without: Vec<(Vec<String>, Vec<String>)>
§stream_output: bool
§assert: Assert
Implementations§
Source§impl Execs
impl Execs
pub fn with_process_builder(self, p: ProcessBuilder) -> Execs
Source§impl Execs
impl Execs
§Configure assertions
Sourcepub fn with_stdout_data(&mut self, expected: impl IntoData) -> &mut Self
pub fn with_stdout_data(&mut self, expected: impl IntoData) -> &mut Self
Verifies that stdout is equal to the given lines.
See compare::assert_e2e
for assertion details.
Sourcepub fn with_stderr_data(&mut self, expected: impl IntoData) -> &mut Self
pub fn with_stderr_data(&mut self, expected: impl IntoData) -> &mut Self
Verifies that stderr is equal to the given lines.
See compare::assert_e2e
for assertion details.
Sourcepub fn with_stdin<S: ToString>(&mut self, expected: S) -> &mut Self
pub fn with_stdin<S: ToString>(&mut self, expected: S) -> &mut Self
Writes the given lines to stdin.
Sourcepub fn with_status(&mut self, expected: i32) -> &mut Self
pub fn with_status(&mut self, expected: i32) -> &mut Self
Verifies the exit code from the process.
This is not necessary if the expected exit code is 0
.
Sourcepub fn without_status(&mut self) -> &mut Self
pub fn without_status(&mut self) -> &mut Self
Removes exit code check for the process.
By default, the expected exit code is 0
.
Sourcepub fn with_stdout_contains<S: ToString>(&mut self, expected: S) -> &mut Self
👎Deprecated: replaced with Execs::with_stdout_data(expected)
pub fn with_stdout_contains<S: ToString>(&mut self, expected: S) -> &mut Self
Execs::with_stdout_data(expected)
Verifies that stdout contains the given contiguous lines somewhere in its output.
See compare
for supported patterns.
Sourcepub fn with_stderr_contains<S: ToString>(&mut self, expected: S) -> &mut Self
👎Deprecated: replaced with Execs::with_stderr_data(expected)
pub fn with_stderr_contains<S: ToString>(&mut self, expected: S) -> &mut Self
Execs::with_stderr_data(expected)
Verifies that stderr contains the given contiguous lines somewhere in its output.
See compare
for supported patterns.
Sourcepub fn with_stdout_does_not_contain<S: ToString>(
&mut self,
expected: S,
) -> &mut Self
👎Deprecated
pub fn with_stdout_does_not_contain<S: ToString>( &mut self, expected: S, ) -> &mut Self
Verifies that stdout does not contain the given contiguous lines.
See compare
for supported patterns.
See note on Self::with_stderr_does_not_contain
.
Sourcepub fn with_stderr_does_not_contain<S: ToString>(
&mut self,
expected: S,
) -> &mut Self
👎Deprecated
pub fn with_stderr_does_not_contain<S: ToString>( &mut self, expected: S, ) -> &mut Self
Verifies that stderr does not contain the given contiguous lines.
See compare
for supported patterns.
Care should be taken when using this method because there is a limitless number of possible things that won’t appear. A typo means your test will pass without verifying the correct behavior. If possible, write the test first so that it fails, and then implement your fix/feature to make it pass.
Sourcepub fn with_stdout_unordered<S: ToString>(&mut self, expected: S) -> &mut Self
👎Deprecated: replaced with Execs::with_stdout_data(expected.unordered())
pub fn with_stdout_unordered<S: ToString>(&mut self, expected: S) -> &mut Self
Execs::with_stdout_data(expected.unordered())
Verifies that all of the stdout output is equal to the given lines, ignoring the order of the lines.
See Execs::with_stderr_unordered
for more details.
Sourcepub fn with_stderr_unordered<S: ToString>(&mut self, expected: S) -> &mut Self
👎Deprecated: replaced with Execs::with_stderr_data(expected.unordered())
pub fn with_stderr_unordered<S: ToString>(&mut self, expected: S) -> &mut Self
Execs::with_stderr_data(expected.unordered())
Verifies that all of the stderr output is equal to the given lines, ignoring the order of the lines.
See compare
for supported patterns.
This is useful when checking the output of cargo build -v
since
the order of the output is not always deterministic.
Recommend use with_stderr_contains
instead unless you really want to
check every line of output.
Be careful when using patterns such as [..]
, because you may end up
with multiple lines that might match, and this is not smart enough to
do anything like longest-match. For example, avoid something like:
[RUNNING] `rustc [..]
[RUNNING] `rustc --crate-name foo [..]
This will randomly fail if the other crate name is bar
, and the
order changes.
Sourcepub fn with_stderr_line_without<S: ToString>(
&mut self,
with: &[S],
without: &[S],
) -> &mut Self
👎Deprecated
pub fn with_stderr_line_without<S: ToString>( &mut self, with: &[S], without: &[S], ) -> &mut Self
Verify that a particular line appears in stderr with and without the given substrings. Exactly one line must match.
The substrings are matched as contains
. Example:
use cargo_test_support::execs;
execs().with_stderr_line_without(
&[
"[RUNNING] `rustc --crate-name build_script_build",
"-C opt-level=3",
],
&["-C debuginfo", "-C incremental"],
);
This will check that a build line includes -C opt-level=3
but does
not contain -C debuginfo
or -C incremental
.
Be careful writing the without
fragments, see note in
with_stderr_does_not_contain
.
Source§impl Execs
impl Execs
§Configure the process
Sourcepub fn stream(&mut self) -> &mut Self
pub fn stream(&mut self) -> &mut Self
Forward subordinate process stdout/stderr to the terminal. Useful for printf debugging of the tests. CAUTION: CI will fail if you leave this in your test!
pub fn arg<T: AsRef<OsStr>>(&mut self, arg: T) -> &mut Self
pub fn args<T: AsRef<OsStr>>(&mut self, args: &[T]) -> &mut Self
pub fn cwd<T: AsRef<OsStr>>(&mut self, path: T) -> &mut Self
pub(crate) fn get_cwd(&self) -> Option<&Path>
pub fn env<T: AsRef<OsStr>>(&mut self, key: &str, val: T) -> &mut Self
pub fn env_remove(&mut self, key: &str) -> &mut Self
Sourcepub fn masquerade_as_nightly_cargo(&mut self, reasons: &[&str]) -> &mut Self
pub fn masquerade_as_nightly_cargo(&mut self, reasons: &[&str]) -> &mut Self
Enables nightly features for testing
The list of reasons should be why nightly cargo is needed. If it is
because of an unstable feature put the name of the feature as the reason,
e.g. &["print-im-a-teapot"]
Sourcepub fn replace_crates_io(&mut self, url: &Url) -> &mut Self
pub fn replace_crates_io(&mut self, url: &Url) -> &mut Self
Overrides the crates.io URL for testing.
Can be used for testing crates-io functionality where alt registries cannot be used.
pub fn overlay_registry(&mut self, url: &Url, path: &str) -> &mut Self
pub fn enable_split_debuginfo_packed(&mut self) -> &mut Self
pub fn enable_mac_dsym(&mut self) -> &mut Self
Source§impl Execs
impl Execs
§Run and verify the process
pub fn exec_with_output(&mut self) -> Result<Output>
pub fn build_command(&mut self) -> Command
pub fn run(&mut self)
Sourcepub fn run_json(&mut self) -> Value
pub fn run_json(&mut self) -> Value
Runs the process, checks the expected output, and returns the first JSON object on stdout.
pub fn run_output(&mut self, output: &Output)
pub(crate) fn verify_checks_output(&self, stdout: &[u8], stderr: &[u8])
pub(crate) fn match_process( &self, process: &ProcessBuilder, ) -> Result<RawOutput>
pub(crate) fn match_output( &self, code: Option<i32>, stdout: &[u8], stderr: &[u8], ) -> Result<()>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Execs
impl RefUnwindSafe for Execs
impl Send for Execs
impl Sync for Execs
impl Unpin for Execs
impl UnwindSafe for Execs
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 776 bytes