pub struct Execs {
Show 16 fields pub(crate) ran: bool, pub(crate) process_builder: Option<ProcessBuilder>, pub(crate) expect_stdout: Option<String>, pub(crate) expect_stdin: Option<String>, pub(crate) expect_stderr: Option<String>, pub(crate) expect_exit_code: Option<i32>, 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_stderr_unordered: Vec<String>, pub(crate) expect_stderr_with_without: Vec<(Vec<String>, Vec<String>)>, pub(crate) expect_json: Option<String>, pub(crate) expect_json_contains_unordered: Option<String>, pub(crate) stream_output: bool,
}

Fields§

§ran: bool§process_builder: Option<ProcessBuilder>§expect_stdout: Option<String>§expect_stdin: Option<String>§expect_stderr: Option<String>§expect_exit_code: Option<i32>§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_stderr_unordered: Vec<String>§expect_stderr_with_without: Vec<(Vec<String>, Vec<String>)>§expect_json: Option<String>§expect_json_contains_unordered: Option<String>§stream_output: bool

Implementations§

Verifies that stdout is equal to the given lines. See compare for supported patterns.

Verifies that stderr is equal to the given lines. See compare for supported patterns.

Writes the given lines to stdin.

Verifies the exit code from the process.

This is not necessary if the expected exit code is 0.

Removes exit code check for the process.

By default, the expected exit code is 0.

Verifies that stdout contains the given contiguous lines somewhere in its output.

See compare for supported patterns.

Verifies that stderr contains the given contiguous lines somewhere in its output.

See compare for supported patterns.

Verifies that stdout contains the given contiguous lines somewhere in its output, and should be repeated number times.

See compare for supported patterns.

Verifies that stdout does not contain the given contiguous lines.

See compare for supported patterns.

See note on Self::with_stderr_does_not_contain.

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.

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.

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:

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.

Verifies the JSON output matches the given JSON.

This is typically used when testing cargo commands that emit JSON. Each separate JSON object should be separated by a blank line. Example:

assert_that(
    p.cargo("metadata"),
    execs().with_json(r#"
        {"example": "abc"}

        {"example": "def"}
    "#)
 );
  • Objects should match in the order given.
  • The order of arrays is ignored.
  • Strings support patterns described in compare.
  • Use "{...}" to match any object.

Verifies JSON output contains the given objects (in any order) somewhere in its output.

CAUTION: Be very careful when using this. Make sure every object is unique (not a subset of one another). Also avoid using objects that could possibly match multiple output lines unless you’re very sure of what you are doing.

See with_json for more detail.

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!

Enables nightly features for testing

The list of reasons should be why nightly cargo is needed. If it is becuase of an unstable feature put the name of the feature as the reason, e.g. &["print-im-a-teapot"]

Overrides the crates.io URL for testing.

Can be used for testing crates-io functionality where alt registries cannot be used.

Runs the process, checks the expected output, and returns the first JSON object on stdout.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

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: 464 bytes