Skip to content

Commit 285b3e4

Browse files
ehussjyn514
authored andcommitted
Document more compiletest headers.
1 parent 94e9e67 commit 285b3e4

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

src/tests/adding.md

+48
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,57 @@ source.
214214
* `error-pattern` checks the diagnostics just like the `ERROR` annotation
215215
without specifying error line. This is useful when the error doesn't give
216216
any span.
217+
* `incremental` runs the test with the `-C incremental` flag and an empty
218+
incremental directory. This should be avoided when possible; you should use
219+
an *incremental mode* test instead. Incremental mode tests support running
220+
the compiler multiple times and verifying that it can load the generated
221+
incremental cache. This flag is for specialized circumstances, like checking
222+
the interaction of codegen unit partitioning with generating an incremental
223+
cache.
224+
* `aux-build` is used to compile additional crates to link. Just pass it the
225+
name of the source file. The source file should be in a directory called
226+
`auxiliary` beside the test file. The aux crate will be built as a dylib if
227+
possible (unless on a platform that does not support them, or
228+
`no-prefer-dynamic` is specified in the aux file). The `-L` flag is used to
229+
find the extern crates.
230+
* `aux-crate` is very similar to `aux-build`, however it uses the `--extern`
231+
flag to link to the extern crate. That allows you to specify the additional
232+
syntax of the `--extern` flag, such as renaming a dependency. For example,
233+
`// aux-crate:foo=bar.rs` will compile `auxiliary/bar.rs` and add make it
234+
available under then name `foo` within the test. This is similar to how
235+
Cargo does dependency renaming.
236+
* `no-prefer-dynamic` will force an auxiliary crate to be built as an rlib
237+
instead of a dylib. When specified in a test, it will remove the use of `-C
238+
prefer-dynamic`. This can be useful in a variety of circumstances. For
239+
example, it can prevent a proc-macro from being built with the wrong crate
240+
type. Or if your test is specifically targeting behavior of other crate
241+
types, it can be used to prevent building with the wrong crate type.
242+
* `force-host` will force the test to build for the host platform instead of
243+
the target. This is useful primarily for auxiliary proc-macros, which need
244+
to be loaded by the host compiler.
245+
* `pretty-mode` for pretty-print tests specifies the mode it should run in.
246+
The default is `normal` if not specified.
247+
* `pretty-compare-only` causes a pretty test to only compare the
248+
pretty-printed output. It will not try to compile the expanded output to
249+
typecheck it. This is needed for a pretty-mode that does not expand to valid
250+
rust, or for other situations where the expanded output cannot be compiled.
251+
* `pretty-expanded` allows a pretty test to also run with
252+
`-Zunpretty=expanded` as a final step, and will also try to compile the
253+
resulting output (without codegen). This is needed because not all code can
254+
be compiled after being expanded. Pretty tests should specify this if they
255+
can. More history about this may be found in [#23616].
256+
* `pp-exact` is used to ensure a pretty-print test results in specific output.
257+
If specified without a value, then it means the pretty-print output should
258+
match the original source. If specified with a value, as in `//
259+
pp-exact:foo.pp`, will ensure that that pretty-printed output matches the
260+
contents of the given file. Otherwise, if `pp-exact` is not specified, then
261+
the pretty-printed output will be pretty-printed one more time, and the
262+
output of the two pretty-printing rounds will be compared to ensure that the
263+
pretty-printed output converges to a steady state.
217264

218265
[`header.rs`]: https://github.com/rust-lang/rust/tree/master/src/tools/compiletest/src/header.rs
219266
[bless]: ./running.md#editing-and-updating-the-reference-files
267+
[#23616]: https://github.com/rust-lang/rust/issues/23616#issuecomment-484999901
220268

221269
<a name="error_annotations"></a>
222270

0 commit comments

Comments
 (0)