Skip to content

Commit 3e91b0f

Browse files
Merge pull request #2670 from rust-lang/rustc_clean
Add a section about `rustc_clean`
2 parents 93447e3 + 83f54db commit 3e91b0f

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/tests/compiletest.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,26 @@ still pass.
187187
cause an Internal Compiler Error (ICE). This is a highly specialized directive
188188
to check that the incremental cache continues to work after an ICE.
189189

190-
[`tests/incremental`]: https://github.com/rust-lang/rust/tree/HEAD/tests/incremental
191-
190+
Incremental tests may use the attribute `#[rustc_clean(...)]` attribute. This attribute compares
191+
the fingerprint from the current compilation session with the previous one.
192+
The first revision should never have an active `rustc_clean` attribute, since it will always be dirty.
193+
194+
In the default mode, it asserts that the fingerprints must be the same.
195+
The attribute takes the following arguments:
196+
197+
* `cfg="<cond>"` — checks the cfg condition `<cond>`, and only runs the check if the config condition evaluates to true.
198+
This can be used to only run the `rustc_clean` attribute in a specific revision.
199+
* `except="<query1>,<query2>,..."` — asserts that the query results for the listed queries must be different,
200+
rather than the same.
201+
* `loaded_from_disk="<query1>,<query2>,..."` — asserts that the query results for the listed queries
202+
were actually loaded from disk (not just marked green).
203+
This can be useful to ensure that a test is actually exercising the deserialization
204+
logic for a particular query result. This can be combined with `except`.
205+
206+
A simple example of a test using `rustc_clean` is the [hello_world test].
207+
208+
[`tests/incremental`]: https://github.com/rust-lang/rust/tree/7b42543/tests/incremental
209+
[hello_world test]: https://github.com/rust-lang/rust/blob/646a3f8c15baefb98dc6e0c1c1ba3356db702d2a/tests/incremental/hello_world.rs
192210

193211
### Debuginfo tests
194212

0 commit comments

Comments
 (0)