Struct trycmd_indygreg_fork::TestCases
source · pub struct TestCases { /* private fields */ }
Expand description
Entry point for running tests
Implementations§
source§impl TestCases
impl TestCases
pub fn new() -> Self
sourcepub fn interrupted(&self, glob: impl AsRef<Path>) -> &Self
pub fn interrupted(&self, glob: impl AsRef<Path>) -> &Self
Overwrite expected status for a test
sourcepub fn default_bin_path(&self, path: impl AsRef<Path>) -> &Self
pub fn default_bin_path(&self, path: impl AsRef<Path>) -> &Self
Set default bin, by path, for commands
sourcepub fn default_bin_name(&self, name: impl AsRef<str>) -> &Self
pub fn default_bin_name(&self, name: impl AsRef<str>) -> &Self
Set default bin, by name, for commands
sourcepub fn env(&self, key: impl Into<String>, value: impl Into<String>) -> &Self
pub fn env(&self, key: impl Into<String>, value: impl Into<String>) -> &Self
Set default environment variable
sourcepub fn register_bin(
&self,
name: impl Into<String>,
path: impl Into<Bin>
) -> &Self
pub fn register_bin( &self, name: impl Into<String>, path: impl Into<Bin> ) -> &Self
Add a bin to the “PATH” for cases to use
sourcepub fn register_bins<N: Into<String>, B: Into<Bin>>(
&self,
bins: impl IntoIterator<Item = (N, B)>
) -> &Self
pub fn register_bins<N: Into<String>, B: Into<Bin>>( &self, bins: impl IntoIterator<Item = (N, B)> ) -> &Self
Add a series of bins to the “PATH” for cases to use
sourcepub fn file_extension_loader(
&self,
extension: impl Into<OsString>,
loader: TryCmdLoader
) -> &Self
pub fn file_extension_loader( &self, extension: impl Into<OsString>, loader: TryCmdLoader ) -> &Self
Define a function used to load a filesystem path into a test.
extension
is the file extension to register the loader for, without
the leading dot. e.g. toml
, json
, or trycmd
.
By default there are loaders for toml
, trycmd
, and md
extensions.
Calling this function with those extensions will overwrite the default
loaders.
sourcepub fn insert_var(
&self,
var: &'static str,
value: impl Into<Cow<'static, str>>
) -> Result<&Self, Error>
pub fn insert_var( &self, var: &'static str, value: impl Into<Cow<'static, str>> ) -> Result<&Self, Error>
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
#[test]
fn cli_tests() {
trycmd_indygreg_fork::TestCases::new()
.case("tests/cmd/*.trycmd")
.insert_var("[VAR]", "value");
}
sourcepub fn extend_vars(
&self,
vars: impl IntoIterator<Item = (&'static str, impl Into<Cow<'static, str>>)>
) -> Result<&Self, Error>
pub fn extend_vars( &self, vars: impl IntoIterator<Item = (&'static str, impl Into<Cow<'static, str>>)> ) -> Result<&Self, Error>
Batch add variables for normalizing output
See insert_var
.