### Function: compile_example Source: https://docs.rs/trycmd/1.2.0/trycmd/cargo/fn.compile_example.html Prepares an example for testing by compiling it. This function is available only when the 'examples' feature flag is enabled. ```APIDOC ## Function: compile_example ### Description Prepares an example for testing. Unlike `cargo_bin!`, this does not inherit all of the current compiler settings. It matches the current target and profile but does not inherit feature flags. ### Parameters - **target_name** (&str) - Required - The name of the example target to compile. - **args** (impl IntoIterator) - Required - Arguments to pass to the compiler. ### Request Example ```rust #[test] fn cli_tests() { trycmd::TestCases::new() .register_bin("example-fixture", trycmd::cargo::compile_example("example-fixture", [])) .case("examples/cmd/*.trycmd"); } ``` ### Response - **Bin** - Returns a `Bin` object representing the compiled example. ``` -------------------------------- ### Initialize and configure TestCases Source: https://docs.rs/trycmd/1.2.0/trycmd/struct.TestCases.html Example showing how to instantiate TestCases and configure test files and output variables. ```rust #[test] fn cli_tests() { trycmd::TestCases::new() .case("tests/cmd/*.trycmd") .insert_var("[VAR]", "value"); } ``` -------------------------------- ### compile_examples Source: https://docs.rs/trycmd/1.2.0/trycmd/cargo/index.html Functions to prepare examples for testing. ```APIDOC ## compile_example ### Description Prepare a specific example for testing. ## compile_examples ### Description Prepare all examples for testing. ``` -------------------------------- ### Compile Example for Testing Source: https://docs.rs/trycmd/1.2.0/trycmd/cargo/fn.compile_example.html Use compile_example to prepare a binary for testing. It matches the current target and profile but does not inherit feature flags, which must be passed in 'args'. Available only on crate feature 'examples'. ```rust #[test] fn cli_tests() { trycmd::TestCases::new() .register_bin("example-fixture", trycmd::cargo::compile_example("example-fixture", [])) .case("examples/cmd/*.trycmd"); } ``` -------------------------------- ### Rust Binary Example Source: https://docs.rs/trycmd/1.2.0/trycmd/index.html A simple Rust main function that prints 'Hello world'. This serves as an example binary for testing with trycmd. ```rust fn main() { println!("Hello world"); } ``` -------------------------------- ### Compile Examples with trycmd::cargo Source: https://docs.rs/trycmd/1.2.0/trycmd/cargo/fn.compile_examples.html Use this function to prepare all examples for testing. It matches the current target and profile but does not inherit feature flags. Pass additional arguments to the compiler via `args`. ```rust #[test] fn cli_tests() { trycmd::TestCases::new() .register_bins(trycmd::cargo::compile_examples([]).unwrap()) .case("examples/cmd/*.trycmd"); } ``` -------------------------------- ### Console Syntax Example for trycmd Source: https://docs.rs/trycmd/1.2.0/trycmd/index.html Example of a test case using console-like syntax within a fenced code block. This format is recognized by trycmd for defining commands and their expected output. ```console ```console $ my-cmd Hello world ``` ``` -------------------------------- ### Minimal trycmd Setup Source: https://docs.rs/trycmd/1.2.0/trycmd/index.html Sets up a minimal test case using trycmd to enumerate test files and run commands. Include this in your `tests/cli_tests.rs` file. ```rust #[test] fn cli_tests() { trycmd::TestCases::new() .case("tests/cmd/*.toml") .case("README.md"); } ``` -------------------------------- ### trycmd::cargo::compile_examples Source: https://docs.rs/trycmd/1.2.0/trycmd/cargo/fn.compile_examples.html Prepares all examples for testing. This function does not inherit all compiler settings like `cargo_bin!`. It matches the current target and profile but excludes feature flags. Additional arguments for the compiler can be passed via the `args` parameter. ```APIDOC ## compile_examples ### Description Prepares all examples for testing. This function does not inherit all compiler settings like `cargo_bin!`. It matches the current target and profile but excludes feature flags. Additional arguments for the compiler can be passed via the `args` parameter. Available on **crate feature`examples`** only. ### Function Signature ```rust pub fn compile_examples<'a>(args: impl IntoIterator) -> Result, Error> ``` ### Parameters #### Arguments - **args** (`impl IntoIterator`) - An iterator of string slices representing arguments to pass to the compiler. ### Returns - `Result, Error>` - An iterator over compiled binaries and their names, or an error if compilation fails. ### Example ```rust #[test] fn cli_tests() { trycmd::TestCases::new() .register_bins(trycmd::cargo::compile_examples([]).unwrap()) .case("examples/cmd/*.trycmd"); } ``` ``` -------------------------------- ### Use cargo_bin in integration tests Source: https://docs.rs/trycmd/1.2.0/trycmd/cargo/macro.cargo_bin.html Example of using the cargo_bin macro to set the default binary path for trycmd test cases. ```rust #[test] fn cli_tests() { trycmd::TestCases::new() .default_bin_path(trycmd::cargo_bin!("bin-fixture")) .case("tests/cmd/*.trycmd"); } ``` -------------------------------- ### Get Cargo Binary Path Source: https://docs.rs/trycmd/1.2.0/trycmd/cargo/fn.cargo_bin_opt.html Use `cargo_bin_opt` to find the path of a binary built by Cargo in integration tests. Returns `None` if the binary does not exist. Compatibility varies with Cargo versions. ```rust pub fn cargo_bin_opt(name: &str) -> Option ``` -------------------------------- ### TestCases::run() Source: https://docs.rs/trycmd/1.2.0/trycmd/struct.TestCases.html Runs the configured tests. This will happen on `drop` if not done explicitly. ```APIDOC ## pub fn run(&self) ### Description Run tests This will happen on `drop` if not done explicitly ``` -------------------------------- ### cmd.toml Schema Overview Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/index.html Overview of the configuration schema for trycmd, detailing the primary structs and enums used to define test command behavior. ```APIDOC ## cmd.toml Schema ### Description The `cmd.toml` file defines the configuration for command-line tests. The `OneShot` struct serves as the top-level entry point for these files. ### Structs - **OneShot**: The top-level data structure in `cmd.toml` files. - **Env**: Defines the environment variables for the command. - **Filesystem**: Defines the filesystem context for the command. ### Enums - **Bin**: Specifies the target binary under test. - **CommandStatus**: Defines the expected exit status for the command. ``` -------------------------------- ### TestCases::register_bin() Source: https://docs.rs/trycmd/1.2.0/trycmd/struct.TestCases.html Adds a binary to the PATH for cases to use. ```APIDOC ## pub fn register_bin( &self, name: impl Into, path: impl Into, ) -> &Self ### Description Add a bin to the “PATH” for cases to use ``` -------------------------------- ### Implement From<&Path> for Bin Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.Bin.html Converts a reference to a Path into a Bin::Path variant. This simplifies creating Bin instances from existing path references. ```rust impl<'a> From<&'a Path> for Bin ``` -------------------------------- ### TestCases::new() Source: https://docs.rs/trycmd/1.2.0/trycmd/struct.TestCases.html Creates a new instance of TestCases. ```APIDOC ## pub fn new() -> Self ### Description Creates a new instance of TestCases. ``` -------------------------------- ### Run trycmd Tests via CLI Source: https://docs.rs/trycmd Commands for generating, updating, and filtering test snapshots. ```bash $ TRYCMD=dump cargo test --test cli_tests ``` ```bash $ TRYCMD=overwrite cargo test --test cli_tests ``` ```bash cargo test --test cli_tests -- cli_tests trycmd=name1 trycmd=name2... ``` -------------------------------- ### Implement CloneToUninit for T (Nightly) Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.Bin.html A nightly-only experimental API for performing copy-assignment to uninitialized memory. Use with caution. ```rust impl CloneToUninit for T where T: Clone, ``` -------------------------------- ### trycmd::schema::Bin Enum Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.Bin.html Documentation for the Bin enum, which represents different ways to specify a binary for testing. ```APIDOC ## Enum Bin ### Variants - **Path(PathBuf)**: Specifies the binary by its file path. - **Name(String)**: Specifies the binary by its name (assumed to be in the system's PATH). - **Ignore**: Indicates that no binary should be used. - **Error(Error)**: Represents an error state related to the binary specification. ``` -------------------------------- ### Implement From<&PathBuf> for Bin Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.Bin.html Converts a reference to a PathBuf into a Bin::Path variant. This provides a convenient way to create Bin instances from PathBuf references. ```rust impl<'a> From<&'a PathBuf> for Bin ``` -------------------------------- ### TestCases::register_bins() Source: https://docs.rs/trycmd/1.2.0/trycmd/struct.TestCases.html Adds a series of binaries to the PATH for cases to use. ```APIDOC ## pub fn register_bins, B: Into>( &self, bins: impl IntoIterator, ) -> &Self ### Description Add a series of bins to the “PATH” for cases to use ``` -------------------------------- ### Generate Snapshots with trycmd Source: https://docs.rs/trycmd/1.2.0/trycmd/index.html Command to generate snapshot files (.stdout, .stderr) for your CLI tests. Run this command to create or update the baseline test results. ```bash $ TRYCMD=dump cargo test --test cli_tests ``` -------------------------------- ### TestCases::default_bin_path() Source: https://docs.rs/trycmd/1.2.0/trycmd/struct.TestCases.html Sets the default binary path for commands. ```APIDOC ## pub fn default_bin_path(&self, path: impl AsRef) -> &Self ### Description Set default bin, by path, for commands ``` -------------------------------- ### TestCases Struct Source: https://docs.rs/trycmd/1.2.0/trycmd/struct.TestCases.html The TestCases struct is the entry point for running tests with trycmd. It allows configuration of test cases, including glob patterns, expected outcomes, binary paths, timeouts, environment variables, and output normalization. ```APIDOC ## Struct TestCases ### Description Entry point for running tests ``` -------------------------------- ### Implement Clone for Bin Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.Bin.html Provides the ability to create a duplicate of a Bin value. This is useful for scenarios where the original value needs to be preserved. ```rust impl Clone for Bin ``` -------------------------------- ### Implement PartialEq for Bin Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.Bin.html Enables equality comparison between Bin values. This allows checking if two Bin variants represent the same binary target. ```rust impl PartialEq for Bin ``` -------------------------------- ### Try Into Conversion Source: https://docs.rs/trycmd/1.2.0/trycmd/struct.TestCases.html Implement `TryInto` for fallible conversions, providing a convenient way to attempt conversion from one type to another. ```rust type Error = >::Error ``` ```rust fn try_into(self) -> Result>::Error> ``` -------------------------------- ### Implement Serialize for Bin Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.Bin.html Allows Bin values to be serialized into a Serde-compatible format. This is essential for outputting configuration or state that includes binary targets. ```rust impl Serialize for Bin ``` -------------------------------- ### Implement Equivalent for Q Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.Bin.html Checks for equivalence between two types, often used in collections for key lookups. This implementation allows comparing Q with K if K can borrow Q. ```rust impl Equivalent for Q where Q: Eq + ?Sized, K: Borrow + ?Sized, ``` -------------------------------- ### TestCases::env() Source: https://docs.rs/trycmd/1.2.0/trycmd/struct.TestCases.html Sets a default environment variable for commands. ```APIDOC ## pub fn env(&self, key: impl Into, value: impl Into) -> &Self ### Description Set default environment variable ``` -------------------------------- ### Implement Debug for Bin Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.Bin.html Allows Bin values to be formatted for debugging output. This is essential for inspecting the state of Bin variants during development. ```rust impl Debug for Bin ``` -------------------------------- ### Implement From> for Bin Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.Bin.html Converts a Result into a Bin variant, mapping Ok to Bin::Path and Err to Bin::Error. This allows for direct conversion of fallible operations into Bin representations. ```rust impl From> for Bin where P: Into, E: Display, ``` -------------------------------- ### Data Conversion and Ownership Traits Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/struct.Env.html Documentation for ToOwned, TryFrom, and TryInto traits used for data transformation and ownership management. ```APIDOC ## ToOwned Trait ### type Owned = T The resulting type after obtaining ownership. ### fn to_owned(&self) -> T Creates owned data from borrowed data. ### fn clone_into(&self, target: &mut T) Uses borrowed data to replace owned data. ## TryFrom / TryInto Traits ### fn try_from(value: U) -> Result Performs the conversion from U to T. ### fn try_into(self) -> Result Performs the conversion from T to U. ``` -------------------------------- ### Bin Enum Trait Implementations Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.Bin.html Details on the various trait implementations for the Bin enum, providing insights into its behavior and capabilities. ```APIDOC ### Trait Implementations #### `impl Clone for Bin` - `fn clone(&self) -> Bin`: Returns a duplicate of the value. - `fn clone_from(&mut self, source: &Self)`: Performs copy-assignment from `source`. #### `impl Debug for Bin` - `fn fmt(&self, f: &mut Formatter<'_>) -> Result`: Formats the value using the given formatter. #### `impl<'de> Deserialize<'de> for Bin` - `fn deserialize<__D>(__deserializer: __D) -> Result`: Deserialize this value from the given Serde deserializer. #### `impl<'a> From<&'a Path> for Bin` - `fn from(other: &'a Path) -> Self`: Converts to this type from `&'a Path`. #### `impl<'a> From<&'a PathBuf> for Bin` - `fn from(other: &'a PathBuf) -> Self`: Converts to this type from `&'a PathBuf`. #### `impl From for Bin` - `fn from(other: PathBuf) -> Self`: Converts to this type from `PathBuf`. #### `impl From> for Bin` where `P: Into`, `E: Display` - `fn from(other: Result) -> Self`: Converts to this type from `Result`. #### `impl JsonSchema for Bin` - `fn schema_name() -> Cow<'static, str>`: The name of the generated JSON Schema. - `fn schema_id() -> Cow<'static, str>`: Returns a string that uniquely identifies the schema produced by this type. - `fn json_schema(generator: &mut SchemaGenerator) -> Schema`: Generates a JSON Schema for this type. - `fn inline_schema() -> bool`: Whether JSON Schemas generated for this type should be included directly in parent schemas. #### `impl PartialEq for Bin` - `fn eq(&self, other: &Bin) -> bool`: Tests for `self` and `other` values to be equal. - `fn ne(&self, other: &Rhs) -> bool`: Tests for `!=`. #### `impl Serialize for Bin` - `fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>`: Serialize this value into the given Serde serializer. #### `impl Eq for Bin` #### `impl StructuralPartialEq for Bin` ``` -------------------------------- ### Verify CLI Output in Markdown Source: https://docs.rs/trycmd Syntax for verifying command output within a console code block in a literate test file. ```console $ my-cmd Hello world ``` -------------------------------- ### Function: cargo_bin_opt Source: https://docs.rs/trycmd/1.2.0/trycmd/cargo/fn.cargo_bin_opt.html Look up the path to a cargo-built binary within an integration test. ```APIDOC ## Function: cargo_bin_opt ### Description Look up the path to a cargo-built binary within an integration test. Returns None if the binary does not exist. ### Signature `pub fn cargo_bin_opt(name: &str) -> Option` ### Parameters - **name** (&str) - Required - The name of the cargo-built binary to locate. ### Cargo Support - **>1.94**: works - **>=1.91, <=1.93**: works with default build-dir - **<=1.92**: works ``` -------------------------------- ### cargo_bin Functions Source: https://docs.rs/trycmd/1.2.0/trycmd/cargo/index.html Functions to look up paths for cargo-built binaries. ```APIDOC ## cargo_bin / cargo_bin_opt ### Description Look up the path to a cargo-built binary within an integration test. ## cargo_bins ### Description Return all the name and path for all binaries built by Cargo. ``` -------------------------------- ### Implement JsonSchema for Bin Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.Bin.html Provides methods for generating a JSON Schema for the Bin enum. This is useful for validation and documentation of data structures. ```rust impl JsonSchema for Bin ``` -------------------------------- ### Implement StructuralPartialEq for Bin Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.Bin.html Enables structural equality comparison for the Bin enum. This compares the structure and values of the enum variants. ```rust impl StructuralPartialEq for Bin ``` -------------------------------- ### TestCases::case() Source: https://docs.rs/trycmd/1.2.0/trycmd/struct.TestCases.html Loads tests from a glob pattern. ```APIDOC ## pub fn case(&self, glob: impl AsRef) -> &Self ### Description Load tests from `glob` ``` -------------------------------- ### Look up cargo-built binary path Source: https://docs.rs/trycmd/1.2.0/trycmd/cargo/fn.cargo_bin.html Use this function to find the path to a binary created by cargo within an integration test. It supports various Cargo versions, with specific notes for versions greater than or equal to 1.91. Panics if no binary is found. ```rust pub fn cargo_bin(name: &str) -> PathBuf ``` -------------------------------- ### TestCases::default_bin_name() Source: https://docs.rs/trycmd/1.2.0/trycmd/struct.TestCases.html Sets the default binary name for commands. ```APIDOC ## pub fn default_bin_name(&self, name: impl AsRef) -> &Self ### Description Set default bin, by name, for commands ``` -------------------------------- ### Implement Deserialize for Bin Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.Bin.html Enables deserialization of Bin values from a Serde deserializer. This is crucial for loading configuration or data that specifies binary targets. ```rust impl<'de> Deserialize<'de> for Bin ``` -------------------------------- ### Define Filesystem Struct Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/struct.Filesystem.html The definition of the Filesystem struct. ```rust pub struct Filesystem { /* private fields */ } ``` -------------------------------- ### Implement From for Bin Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.Bin.html Converts an owned PathBuf into a Bin::Path variant. This is useful when you have a PathBuf and need to represent it as a Bin. ```rust impl From for Bin ``` -------------------------------- ### Overwrite Snapshots with trycmd Source: https://docs.rs/trycmd/1.2.0/trycmd/index.html Command to overwrite existing snapshot files with the current command outputs. Use this when your CLI's behavior has intentionally changed. ```bash $ TRYCMD=overwrite cargo test --test cli_tests ``` -------------------------------- ### Implement From for T Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.Bin.html A trivial implementation of From that returns the argument unchanged. This is a common identity conversion. ```rust impl From for T ``` -------------------------------- ### trycmd::cargo::cargo_bin Source: https://docs.rs/trycmd/1.2.0/trycmd/all.html Macro to locate a cargo binary for testing purposes. ```APIDOC ## cargo::cargo_bin ### Description A macro used to resolve the path to a cargo binary within the test environment. ### Parameters - **name** (string) - Required - The name of the binary to locate. ``` -------------------------------- ### Enable Debugging in trycmd Source: https://docs.rs/trycmd/1.2.0/trycmd/index.html Command to enable debug output for trycmd. This helps in understanding the internal workings of the test harness during execution. ```bash cargo test -F trycmd/debug ``` -------------------------------- ### TestCases::timeout() Source: https://docs.rs/trycmd/1.2.0/trycmd/struct.TestCases.html Sets the default timeout for commands. ```APIDOC ## pub fn timeout(&self, time: Duration) -> &Self ### Description Set default timeout for commands ``` -------------------------------- ### trycmd::schema::TestCases Source: https://docs.rs/trycmd/1.2.0/trycmd/all.html Struct representing a collection of test cases for the trycmd framework. ```APIDOC ## struct TestCases ### Description Represents a suite of test cases to be executed by the trycmd runner. ``` -------------------------------- ### Conversion and Ownership Traits Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/struct.Filesystem.html Interfaces for type conversion (TryFrom/TryInto) and ownership management (ToOwned). ```APIDOC ## impl TryFrom for T ### Description Performs a fallible conversion from type U to type T. ## impl TryInto for T ### Description Performs a fallible conversion into type U. ## impl ToOwned for T ### Description Creates owned data from borrowed data, usually by cloning. ``` -------------------------------- ### Try From Conversion Source: https://docs.rs/trycmd/1.2.0/trycmd/struct.TestCases.html Implement `TryFrom` for fallible conversions between types. The `Error` type indicates conversion failures. ```rust type Error = Infallible ``` ```rust fn try_from(value: U) -> Result>::Error> ``` -------------------------------- ### Memory Management and Debugging Traits Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/struct.Env.html Documentation for pointer dereferencing, object dropping, and debug data conversion. ```APIDOC ## Memory Management ### unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T Mutably dereferences the given pointer. ### unsafe fn drop(ptr: usize) Drops the object pointed to by the given pointer. ## ToDebug Trait ### fn to_debug(&self) -> Data Converts the object into a debug-friendly data format. ``` -------------------------------- ### Blanket Implementations for OneShot Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/struct.OneShot.html Details the blanket implementations available for types that implement certain traits, including `OneShot`. ```APIDOC ## Blanket Implementations for OneShot ### impl Any for T - `fn type_id(&self) -> TypeId`: Gets the `TypeId` of `self`. ### impl Borrow for T - `fn borrow(&self) -> &T`: Immutably borrows from an owned value. ### impl BorrowMut for T - `fn borrow_mut(&mut self) -> &mut T`: Mutably borrows from an owned value. ### impl CloneToUninit for T - `unsafe fn clone_to_uninit(&self, dest: *mut u8)`: Performs copy-assignment from `self` to `dest`. ### impl DynClone for T - `fn __clone_box(&self, _: Private) -> *mut ()` ### impl Equivalent for Q - `fn equivalent(&self, key: &K) -> bool`: Checks if this value is equivalent to the given key. ### impl Equivalent for Q - `fn equivalent(&self, key: &K) -> bool`: Compare self to `key` and return `true` if they are equal. ### impl From for T - `fn from(t: T) -> T`: Returns the argument unchanged. ### impl Into for T - `fn into(self) -> U`: Calls `U::from(self)`. ### impl IntoEither for T - `fn into_either(self, into_left: bool) -> Either`: Converts `self` into a `Left` variant of `Either` if `into_left` is `true`. Converts `self` into a `Right` variant of `Either` otherwise. - `fn into_either_with(self, into_left: F) -> Either`: Converts `self` into a `Left` variant of `Either` if `into_left(&self)` returns `true`. Converts `self` into a `Right` variant of `Either` otherwise. ### impl Pointable for T - `const ALIGN: usize`: The alignment of pointer. - `type Init = T` - `unsafe fn init(init: ::Init) -> usize`: Initializes a with the given initializer. ``` -------------------------------- ### Struct OneShot Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/struct.OneShot.html Represents top-level data in `cmd.toml` files. ```APIDOC ## Struct OneShot ### Description Top-level data in `cmd.toml` files. ### Summary ```rust pub struct OneShot { /* private fields */ } ``` ``` -------------------------------- ### trycmd::schema::Env Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/struct.Env.html The Env struct is used to describe a command's environment. It provides methods for managing environment variables for command execution. ```APIDOC ## Struct Env ### Description Describe command’s environment. ### Methods This struct implements several traits, including `Clone`, `Debug`, `Default`, `Deserialize`, `JsonSchema`, `PartialEq`, `Serialize`, `Eq`, and `StructuralPartialEq`. #### `Clone` Trait - `fn clone(&self) -> Env`: Returns a duplicate of the value. - `fn clone_from(&mut self, source: &Self)`: Performs copy-assignment from `source`. #### `Debug` Trait - `fn fmt(&self, f: &mut Formatter<'_>) -> Result`: Formats the value using the given formatter. #### `Default` Trait - `fn default() -> Env`: Returns the “default value” for a type. #### `Deserialize` Trait - `fn deserialize<__D>(__deserializer: __D) -> Result`: Deserialize this value from the given Serde deserializer. #### `JsonSchema` Trait - `fn schema_name() -> Cow<'static, str>`: The name of the generated JSON Schema. - `fn schema_id() -> Cow<'static, str>`: Returns a string that uniquely identifies the schema produced by this type. - `fn json_schema(generator: &mut SchemaGenerator) -> Schema`: Generates a JSON Schema for this type. - `fn inline_schema() -> bool`: Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the `$ref` keyword. #### `PartialEq` Trait - `fn eq(&self, other: &Env) -> bool`: Tests for `self` and `other` values to be equal, and is used by `==`. - `fn ne(&self, other: &Rhs) -> bool`: Tests for `!=`. #### `Serialize` Trait - `fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>`: Serialize this value into the given Serde serializer. #### `Eq` Trait (No methods defined beyond trait requirements) #### `StructuralPartialEq` Trait (No methods defined beyond trait requirements) ### Auto Trait Implementations - `Freeze` - `RefUnwindSafe` - `Send` - `Sync` - `Unpin` - `UnsafeUnpin` - `UnwindSafe` ### Blanket Implementations This struct also benefits from blanket implementations for traits like `Any`, `Borrow`, `BorrowMut`, `CloneToUninit`, `DynClone`, `Equivalent`, `From`, `Into`, `IntoEither`, and `Pointable`. ``` -------------------------------- ### cargo_bin Source: https://docs.rs/trycmd/1.2.0/trycmd/cargo/index.html Macro to retrieve the absolute path to a binary target's executable. ```APIDOC ## cargo_bin (Macro) ### Description Returns the absolute path to a binary target's executable. ### Usage `cargo_bin!(name)` ``` -------------------------------- ### macro_rules! cargo_bin Source: https://docs.rs/trycmd/1.2.0/trycmd/cargo/macro.cargo_bin.html The cargo_bin macro retrieves the absolute path to a binary target's executable. It requires the binary target name as an expression. ```APIDOC ## cargo_bin ### Description The absolute path to a binary target’s executable. The bin_target_name is the name of the binary target, exactly as-is. Note: This is only set when building an integration test or benchmark. ### Parameters - **bin_target_name** (expr) - Optional - The name of the binary target. ### Request Example #[test] fn cli_tests() { trycmd::TestCases::new() .default_bin_path(trycmd::cargo_bin!("bin-fixture")) .case("tests/cmd/*.trycmd"); } ``` -------------------------------- ### Trait Implementations for OneShot Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/struct.OneShot.html Details the various trait implementations available for the `OneShot` struct. ```APIDOC ## Trait Implementations for OneShot ### impl Clone for OneShot - `fn clone(&self) -> OneShot`: Returns a duplicate of the value. - `fn clone_from(&mut self, source: &Self)`: Performs copy-assignment from `source`. ### impl Debug for OneShot - `fn fmt(&self, f: &mut Formatter<'_>) -> Result`: Formats the value using the given formatter. ### impl Default for OneShot - `fn default() -> OneShot`: Returns the “default value” for a type. ### impl<'de> Deserialize<'de> for OneShot - `fn deserialize<__D>(__deserializer: __D) -> Result`: Deserialize this value from the given Serde deserializer. ### impl JsonSchema for OneShot - `fn schema_name() -> Cow<'static, str>`: The name of the generated JSON Schema. - `fn schema_id() -> Cow<'static, str>`: Returns a string that uniquely identifies the schema produced by this type. - `fn json_schema(generator: &mut SchemaGenerator) -> Schema`: Generates a JSON Schema for this type. - `fn inline_schema() -> bool`: Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the `$ref` keyword. ### impl PartialEq for OneShot - `fn eq(&self, other: &OneShot) -> bool`: Tests for `self` and `other` values to be equal, and is used by `==`. - `fn ne(&self, other: &Rhs) -> bool`: Tests for `!=`. ### impl Serialize for OneShot - `fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>`: Serialize this value into the given Serde serializer. ### impl Eq for OneShot ### impl StructuralPartialEq for OneShot ``` -------------------------------- ### TestCases::insert_var() Source: https://docs.rs/trycmd/1.2.0/trycmd/struct.TestCases.html Adds a variable for normalizing output. Variable names must be surrounded by `[]` and consist of uppercase letters. Reserved names include `[..]`, `[EXE]`, `[CWD]`, and `[ROOT]`. ```APIDOC ## pub fn insert_var( &self, var: &'static str, value: impl Into>, ) -> Result<&Self, Error> ### Description Add a variable for normalizing output Variable names must be * Surrounded by `[]` * Consist of uppercase letters Variables will be preserved through `TRYCMD=overwrite` / `TRYCMD=dump`. **NOTE:** We do basic search/replaces so new any new output will blindly be replaced. Reserved names: * `[..]` * `[EXE]` * `[CWD]` * `[ROOT]` ### Example ```rust #[test] fn cli_tests() { trycmd::TestCases::new() .case("tests/cmd/*.trycmd") .insert_var("[VAR]", "value"); } ``` ``` -------------------------------- ### Auto Trait Implementations for OneShot Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/struct.OneShot.html Lists the auto trait implementations for the `OneShot` struct. ```APIDOC ## Auto Trait Implementations for OneShot - `impl Freeze for OneShot` - `impl RefUnwindSafe for OneShot` - `impl Send for OneShot` - `impl Sync for OneShot` - `impl Unpin for OneShot` - `impl UnsafeUnpin for OneShot` - `impl UnwindSafe for OneShot` ``` -------------------------------- ### Retrieve Cargo Binaries Source: https://docs.rs/trycmd/1.2.0/trycmd/cargo/fn.cargo_bins.html Returns an iterator yielding tuples of binary names and their PathBuf locations. Requires Cargo version 1.94 or higher. ```rust pub fn cargo_bins() -> impl Iterator ``` -------------------------------- ### TryFrom Trait Source: https://docs.rs/trycmd/1.2.0/trycmd/struct.Error.html Provides a method for fallible conversion from one type to another. ```APIDOC ### impl TryFrom for T where U: Into, #### type Error = Infallible ### Description The type returned in the event of a conversion error. #### fn try_from(value: U) -> Result>::Error> ### Description Performs the conversion. ### Method fn ### Endpoint N/A (Method within a trait) ### Parameters - **value** (U) - Required - The value to convert. ### Response #### Success Response (200) - **Result** - The result of the conversion. ``` -------------------------------- ### Filter trycmd Tests by Name Source: https://docs.rs/trycmd/1.2.0/trycmd/index.html Command to filter which tests are run based on names provided after the test suite name. Useful for running specific subsets of tests. ```bash cargo test --test cli_tests -- cli_tests trycmd=name1 trycmd=name2... ``` -------------------------------- ### into_either_with Method Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.CommandStatus.html Converts a value into an `Either` variant based on a predicate. ```APIDOC #### fn into_either_with(self, into_left: F) -> Either ### Description Converts `self` into a `Left` variant of `Either` if `into_left(&self)` returns `true`. Converts `self` into a `Right` variant of `Either` otherwise. ### Parameters #### Closure - **into_left** (F) - A closure that takes a reference to `self` and returns a boolean. If `true`, `self` becomes `Left`; otherwise, it becomes `Right`. ``` -------------------------------- ### ToDebug Trait Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.CommandStatus.html Enables conversion to a debuggable data format. ```APIDOC ## impl ToDebug for D ### Description Enables conversion to a debuggable data format. #### fn to_debug(&self) -> Data Converts the object to a debuggable `Data` type. ``` -------------------------------- ### Define TestCases structure Source: https://docs.rs/trycmd/1.2.0/trycmd/struct.TestCases.html The internal structure definition for TestCases. ```rust pub struct TestCases { /* private fields */ } ``` -------------------------------- ### TryFrom and TryInto Traits Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.CommandStatus.html Facilitates fallible type conversions. ```APIDOC ## impl TryFrom for T ### Description Facilitates fallible type conversions from type `U` to type `T`. #### type Error = Infallible The type returned in the event of a conversion error. #### fn try_from(value: U) -> Result>::Error> Performs the conversion. ## impl TryInto for T ### Description Facilitates fallible type conversions from type `T` to type `U`. #### type Error = >::Error The type returned in the event of a conversion error. #### fn try_into(self) -> Result>::Error> Performs the conversion. ``` -------------------------------- ### cargo_bin Function Source: https://docs.rs/trycmd/1.2.0/trycmd/cargo/fn.cargo_bin.html Looks up the path to a cargo-built binary within an integration test. Supports various Cargo versions. ```APIDOC ## Function cargo_bin ### Description Look up the path to a cargo-built binary within an integration test. Cargo support: * `>1.94`: works * `>=1.91,<=1.93`: works with default `build-dir` * `<=1.92`: works ### Signature ```rust pub fn cargo_bin(name: &str) -> PathBuf ``` ### Parameters #### Path Parameters - **name** (str) - Required - The name of the cargo-built binary to look up. ### Panic Panics if no binary is found. ``` -------------------------------- ### TryFrom and TryInto Conversion Traits Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/struct.OneShot.html Interfaces for fallible type conversions. ```APIDOC ## impl TryFrom for T ### Methods - **try_from(value: U) -> Result**: Performs the conversion. ## impl TryInto for T ### Methods - **try_into(self) -> Result**: Performs the conversion. ``` -------------------------------- ### Memory Pointer Operations Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/struct.Filesystem.html Functions for dereferencing and dropping objects via raw pointers. ```APIDOC ## unsafe fn deref<'a>(ptr: usize) -> &'a T ### Description Dereferences the given pointer to return a reference. ## unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T ### Description Mutably dereferences the given pointer to return a mutable reference. ## unsafe fn drop(ptr: usize) ### Description Drops the object pointed to by the given pointer. ``` -------------------------------- ### Error Struct Source: https://docs.rs/trycmd/1.2.0/trycmd/struct.Error.html Details about the Error struct and its constructor. ```APIDOC ## Struct Error ### Summary ```rust pub struct Error { /* private fields */ } ``` ### Constructor #### pub fn new(inner: impl Display) -> Error Creates a new Error instance with the given inner error implementing the Display trait. ``` -------------------------------- ### Define Env struct Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/struct.Env.html The definition of the Env struct as it appears in the trycmd crate. ```rust pub struct Env { /* private fields */ } ``` -------------------------------- ### Trait: TryFrom / TryInto Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.Bin.html Defines fallible conversion between types. ```APIDOC ## TryFrom / TryInto Traits ### Description Provides mechanisms for performing fallible conversions between types. ### Associated Types - **Error** (Infallible) - The type returned in the event of a conversion error. ### Methods - **try_from(value: U) -> Result** - Performs the conversion from U to T. - **try_into(self) -> Result** - Performs the conversion from T to U. ``` -------------------------------- ### Pointable Trait Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.CommandStatus.html Provides methods for managing raw pointers and their associated data. ```APIDOC ## impl Pointable for T ### Description Provides methods for managing raw pointers and their associated data. #### const ALIGN: usize The alignment of pointer. #### type Init = T The type for initializers. #### unsafe fn init(init: ::Init) -> usize Initializes a with the given initializer. #### unsafe fn deref<'a>(ptr: usize) -> &'a T Dereferences the given pointer. #### unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T Mutably dereferences the given pointer. #### unsafe fn drop(ptr: usize) Drops the object pointed to by the given pointer. ``` -------------------------------- ### Implement Any for T Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.Bin.html Provides runtime type information for any type T. This is a fundamental trait for dynamic dispatch and type introspection. ```rust impl Any for T where T: 'static + ?Sized, ``` -------------------------------- ### TestCases::extend_vars() Source: https://docs.rs/trycmd/1.2.0/trycmd/struct.TestCases.html Batch adds variables for normalizing output. See `TestCases::insert_var` for details. ```APIDOC ## pub fn extend_vars( &self, vars: impl IntoIterator>)>, ) -> Result<&Self, Error> ### Description Batch add variables for normalizing output See `TestCases::insert_var`. ``` -------------------------------- ### Implement Into for T Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.Bin.html Provides a generic way to convert a type T into a type U, provided that U implements From. This is the inverse of the From trait. ```rust impl Into for T where U: From, ``` -------------------------------- ### Implement DynClone for T Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.Bin.html Provides dynamic cloning capabilities for types that implement Clone. This is often used in trait object scenarios. ```rust impl DynClone for T where T: Clone, ``` -------------------------------- ### ToString Trait Source: https://docs.rs/trycmd/1.2.0/trycmd/struct.Error.html Provides a method to convert a value into a String. ```APIDOC ### impl ToString for T where T: Display + ?Sized, #### fn to_string(&self) -> String ### Description Converts the given value to a `String`. ### Method fn ### Endpoint N/A (Method within a trait) ### Parameters - **self** - Required - The value to convert. ### Response #### Success Response (200) - **String** - The string representation of the value. ``` -------------------------------- ### Define cargo_bin macro signature Source: https://docs.rs/trycmd/1.2.0/trycmd/cargo/macro.cargo_bin.html The macro definition for cargo_bin, which accepts an optional binary target name. ```rust macro_rules! cargo_bin { () => { ... }; ($bin_target_name:expr) => { ... }; } ``` -------------------------------- ### Temporarily Override Results in trycmd Source: https://docs.rs/trycmd/1.2.0/trycmd/index.html Demonstrates how to temporarily override test results by specifying a failing case. This is useful for debugging or handling known issues. ```rust #[test] fn cli_tests() { trycmd::TestCases::new() .case("tests/cmd/*.toml") .case("README.md") // See Issue #314 .fail("tests/cmd/buggy-case.toml"); } ``` -------------------------------- ### Function: cargo_bins Source: https://docs.rs/trycmd/1.2.0/trycmd/cargo/fn.cargo_bins.html Retrieves an iterator over all binary names and their corresponding paths built by Cargo. ```APIDOC ## Function: cargo_bins ### Description Returns an iterator containing the name and path for all binaries built by Cargo. ### Signature `pub fn cargo_bins() -> impl Iterator` ### Requirements - Cargo version: >1.94 ``` -------------------------------- ### Bin Enum Definition Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.Bin.html Defines the Bin enum with variants for Path, Name, Ignore, and Error. Use this enum to specify binary targets for testing. ```rust pub enum Bin { Path(PathBuf), Name(String), Ignore, Error(Error), } ``` -------------------------------- ### TryInto Trait Source: https://docs.rs/trycmd/1.2.0/trycmd/struct.Error.html Provides a method for fallible conversion into another type. ```APIDOC ### impl TryInto for T where U: TryFrom, #### type Error = >::Error ### Description The type returned in the event of a conversion error. #### fn try_into(self) -> Result>::Error> ### Description Performs the conversion. ### Method fn ### Endpoint N/A (Method within a trait) ### Parameters - **self** - Required - The value to convert. ### Response #### Success Response (200) - **Result** - The result of the conversion. ``` -------------------------------- ### Error Implementations Source: https://docs.rs/trycmd/1.2.0/trycmd/struct.Error.html Implementations of standard traits for the Error struct. ```APIDOC ## Implementations ### impl Clone for Error #### fn clone(&self) -> Error Returns a duplicate of the value. #### fn clone_from(&mut self, source: &Self) Performs copy-assignment from `source`. ### impl Debug for Error #### fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> Formats the value using the given formatter. ### impl Display for Error #### fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> Formats the value using the given formatter. ### impl Error for Error #### fn source(&self) -> Option<&(dyn Error + 'static)> Returns the lower-level source of this error, if any. #### fn description(&self) -> &str Deprecated since 1.42.0: Use the Display impl or to_string(). #### fn cause(&self) -> Option<&dyn Error> Deprecated since 1.33.0: replaced by Error::source, which can support downcasting. #### fn provide<'a>(&'a self, request: &mut Request<'a>) This is a nightly-only experimental API. (`error_generic_member_access`) Provides type-based access to context intended for error reports. ### impl<'s> From<&'s String> for Error #### fn from(other: &'s String) -> Error Converts to this type from the input type. ### impl<'s> From<&'s str> for Error #### fn from(other: &'s str) -> Error Converts to this type from the input type. ### impl From for Error #### fn from(other: String) -> Error Converts to this type from the input type. ### impl PartialEq for Error #### fn eq(&self, other: &Error) -> bool Tests for `self` and `other` values to be equal, and is used by `==`. #### fn ne(&self, other: &Rhs) -> bool Tests for `!=`. ### impl Eq for Error ``` -------------------------------- ### Pointer Manipulation Functions Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/struct.OneShot.html Low-level unsafe functions for dereferencing and dropping pointers. ```APIDOC ## unsafe fn deref<'a>(ptr: usize) -> &'a T ### Description Dereferences the given pointer to return an immutable reference. ## unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T ### Description Mutably dereferences the given pointer to return a mutable reference. ## unsafe fn drop(ptr: usize) ### Description Drops the object pointed to by the given pointer. ``` -------------------------------- ### Trait: Pointable Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/enum.Bin.html Defines methods for pointer manipulation, including alignment, initialization, and dereferencing. ```APIDOC ## Pointable Trait ### Description Provides an interface for types that can be pointed to, supporting memory alignment and lifecycle management. ### Associated Types - **Init** (T) - The type for initializers. ### Constants - **ALIGN** (usize) - The alignment of the pointer. ### Methods - **init(init: Init) -> usize** (unsafe) - Initializes a with the given initializer. - **deref<'a>(ptr: usize) -> &'a T** (unsafe) - Dereferences the given pointer. - **deref_mut<'a>(ptr: usize) -> &'a mut T** (unsafe) - Mutably dereferences the given pointer. - **drop(ptr: usize)** (unsafe) - Drops the object pointed to by the given pointer. ``` -------------------------------- ### Define OneShot struct Source: https://docs.rs/trycmd/1.2.0/trycmd/schema/struct.OneShot.html The definition of the OneShot struct as it appears in the trycmd schema. ```rust pub struct OneShot { /* private fields */ } ``` -------------------------------- ### Convert to Debug Data Source: https://docs.rs/trycmd/1.2.0/trycmd/struct.TestCases.html Implement `ToDebug` trait to convert a type into its `Data` representation for debugging purposes. ```rust fn to_debug(&self) -> Data ``` -------------------------------- ### TryFrom Trait Source: https://docs.rs/trycmd/1.2.0/trycmd/struct.TestCases.html The TryFrom trait allows for fallible conversions from one type into another. It is the reciprocal of TryInto. ```APIDOC ## impl TryFrom for T where U: Into, ### Description Provides a fallible way to convert a value of type `U` into a value of type `T`. ### Method `try_from` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **Result>::Error>** - A `Result` containing either the converted value of type `T` or an error. #### Response Example None ### Associated Types #### type Error = Infallible - **Description**: The type returned in the event of a conversion error. For `TryFrom` implementations where conversion is infallible, this is `std::convert::Infallible`. ```