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]

[src]

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.

[src]

Return a std::process::Command object that can be used to execute the binary.

[src]

Construct a path relative to our test directory.

let testdir = TestDir::new("touch", "path_builds_paths");
let mut cmd = testdir.cmd();
cmd
  .arg("example.txt")
  .expect_success();
assert!(testdir.path("example.txt").exists());

[src]

Return a path relative to the source directory of the current crate. Useful for finding fixtures.

[src]

Create a file in our test directory with the specified contents.

[src]

If path does not point to valid path, fail the current test.

[src]

If path does not point to valid path, fail the current test.

[src]

Verify that the file contains the specified data.

[src]

Verify that the contents of the file match the specified pattern. Someday this should support std::str::pattern::Pattern so that we can support both strings and regular expressions, but that hasn't been stabilized yet.

[src]

Verify that the contents of the file do not match the specified pattern. Someday this should support std::str::pattern::Pattern so that we can support both strings and regular expressions, but that hasn't been stabilized yet.

Trait Implementations

Auto Trait Implementations

impl Send for TestDir

impl Sync for TestDir