|
1 | 1 | //! Routines for comparing and diffing output.
|
2 | 2 | //!
|
3 |
| -//! # Patterns |
| 3 | +//! # Deprecated comparisons |
| 4 | +//! |
| 5 | +//! Cargo's tests are in transition from internal-only pattern and normalization routines used in |
| 6 | +//! asserts like [`crate::Execs::with_stdout`] to [`assert_e2e`] and [`assert_ui`]. |
| 7 | +//! |
| 8 | +//! ## Patterns |
4 | 9 | //!
|
5 | 10 | //! Many of these functions support special markup to assist with comparing
|
6 | 11 | //! text that may vary or is otherwise uninteresting for the test at hand. The
|
|
22 | 27 | //! can use this to avoid duplicating the `with_stderr` call like:
|
23 | 28 | //! `if cfg!(target_env = "msvc") {e.with_stderr("...[DIRTY]...");} else {e.with_stderr("...");}`.
|
24 | 29 | //!
|
25 |
| -//! # Normalization |
| 30 | +//! ## Normalization |
26 | 31 | //!
|
27 | 32 | //! In addition to the patterns described above, the strings are normalized
|
28 | 33 | //! in such a way to avoid unwanted differences. The normalizations are:
|
@@ -86,6 +91,19 @@ macro_rules! regex {
|
86 | 91 | /// Other heuristics are applied to try to ensure Windows-style paths aren't
|
87 | 92 | /// a problem.
|
88 | 93 | /// - Carriage returns are removed, which can help when running on Windows.
|
| 94 | +/// |
| 95 | +/// # Example |
| 96 | +/// |
| 97 | +/// ```no_run |
| 98 | +/// # use cargo_test_support::compare::assert_e2e; |
| 99 | +/// # use cargo_test_support::file; |
| 100 | +/// # let p = cargo_test_support::project().build(); |
| 101 | +/// # let stdout = ""; |
| 102 | +/// assert_e2e().eq(stdout, file!["stderr.term.svg"]); |
| 103 | +/// ``` |
| 104 | +/// ```console |
| 105 | +/// $ SNAPSHOTS=overwrite cargo test |
| 106 | +/// ``` |
89 | 107 | pub fn assert_ui() -> snapbox::Assert {
|
90 | 108 | let mut subs = snapbox::Redactions::new();
|
91 | 109 | subs.extend(MIN_LITERAL_REDACTIONS.into_iter().cloned())
|
@@ -129,6 +147,18 @@ pub fn assert_ui() -> snapbox::Assert {
|
129 | 147 | /// Other heuristics are applied to try to ensure Windows-style paths aren't
|
130 | 148 | /// a problem.
|
131 | 149 | /// - Carriage returns are removed, which can help when running on Windows.
|
| 150 | +/// |
| 151 | +/// # Example |
| 152 | +/// |
| 153 | +/// ```no_run |
| 154 | +/// # use cargo_test_support::compare::assert_e2e; |
| 155 | +/// # use cargo_test_support::str; |
| 156 | +/// # let p = cargo_test_support::project().build(); |
| 157 | +/// assert_e2e().eq(p.read_lockfile(), str![]); |
| 158 | +/// ``` |
| 159 | +/// ```console |
| 160 | +/// $ SNAPSHOTS=overwrite cargo test |
| 161 | +/// ``` |
132 | 162 | pub fn assert_e2e() -> snapbox::Assert {
|
133 | 163 | let mut subs = snapbox::Redactions::new();
|
134 | 164 | subs.extend(MIN_LITERAL_REDACTIONS.into_iter().cloned())
|
|
0 commit comments