You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/doc/contrib/src/tests/writing.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,6 +64,16 @@ test.
64
64
- See [`support::compare`] for an explanation of the string pattern matching.
65
65
Patterns are used to make it easier to match against the expected output.
66
66
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
+
67
77
#### Testing Nightly Features
68
78
69
79
If you are testing a Cargo feature that only works on "nightly" Cargo, then
0 commit comments