Skip to content

Commit a0a0ab4

Browse files
committed
docs: Added assert_dir_layout() to testing docs
1 parent dfacc6c commit a0a0ab4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/doc/contrib/src/tests/writing.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ test.
6464
- See [`support::compare`] for an explanation of the string pattern matching.
6565
Patterns are used to make it easier to match against the expected output.
6666

67+
#### Filesystem layout testing
68+
69+
Tests often to need to verify Cargo created/removed files.
70+
The `CargoPathExt` trait (implemented by `Path` and `PathBuf`) provides a `assert_dir_layout()` to verify the files in a directory (including nested directories).
71+
This takes a snapshot of file paths for the given directory and asserts that all files are present and no new files have been created.
72+
This function also takes a list of patterns to ignore from the snapshot to make working with platform specific files easier.
73+
74+
Note: You will commonly need to call `unordered()` before passing your snapshot to deal with platform differences like binaries having `.exe` on Windows.
75+
`assert_build_dir_layout` is a more specialized version of `assert_dir_layout()` that is automatically unordered and ignores common platform specific files designed for the Cargo build cache.
76+
6777
#### Testing Nightly Features
6878

6979
If you are testing a Cargo feature that only works on "nightly" Cargo, then

0 commit comments

Comments
 (0)