Skip to content

Commit

Permalink
Fixed doc test
Browse files Browse the repository at this point in the history
  • Loading branch information
la10736 committed Jul 5, 2023
1 parent f1d7c5f commit 7c6d3f2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,28 @@ async fn single(#[future] base: u32, #[case] expected: u32, #[future(awt)] #[cas
}
```

### Files path as input arguments

If you need to create a test for each file in a given location you can use
`#[files("glob path syntax")]` attribute to generate a test for each file that
satisfy the given glob path.

```rust
# use rstest::rstest;
# use std::path::{Path, PathBuf};
# fn check_file(path: &Path) -> bool { true };
#[rstest]
fn for_each_file(#[files("src/**/*.rs")] #[exclude("test")] path: PathBuf) {
assert!(check_file(&path))
}
```

The default behavior is to ignore the files that starts with `"."` but you can
modify this by use `#[include_dot_files]` attribute. The `files` attribute can be
used more than once on the same variable and you can also create some custom
exclusion rules with the `#[exclude("regex")]` attributes that filter out all
paths that verify the regular expression.

### Default timeout

You can set a default timeout for test using the `RSTEST_TIMEOUT` environment variable.
Expand Down
2 changes: 1 addition & 1 deletion rstest_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ pub fn fixture(
/// # use std::path::{Path, PathBuf};
/// # fn check_file(path: &Path) -> bool { true };
/// #[rstest]
/// fn for_each_file(#[files("resources/valid_cases/*")] path: PathBuf) {
/// fn for_each_file(#[files("src/**/*.rs")] #[exclude("test")] path: PathBuf) {
/// assert!(check_file(&path))
/// }
/// ```
Expand Down

0 comments on commit 7c6d3f2

Please sign in to comment.