Struct cli_test_dir::TestDir
[−]
[src]
pub struct TestDir { /* fields omitted */ }
This code is inspired by the WorkDir
pattern that BurntSushi uses to
test CLI tools like ripgrep
and xsv
.
Methods
impl TestDir
[src]
fn new(bin_name: &str, test_name: &str) -> TestDir
Create a new TestDir
for the current test. You must specify
bin_name
(the name of a binary built by the current crate) and
test_name
(a unique name for the current test).
If our output directory exists from a previous test run, it will be deleted.
fn cmd(&self) -> Command
Return a std::process::Command
object that can be used to execute
the binary.
fn src_path<P: AsRef<Path>>(&self, path: P) -> PathBuf
Return a path relative to the source directory of the current crate. Useful for finding fixtures.
fn expect_path<P: AsRef<Path>>(&self, path: P)
If path
does not point to valid path, fail the current test.