Skip to content

Commit 4470641

Browse files
jyn514JohnTitor
andauthored
Improve instructions for adding a new test (#881)
* Improve instructions for adding a new test - Add a section for library tests - Expand section on rustdoc tests * Address review comments - Say what should be considered a library test - Mention adding error numbers to doc tests - Link to #ui section - Line wrapping * Fix incorrect link It shouldn't have been a link in the first place. Co-authored-by: Yuki Okushi <[email protected]> Co-authored-by: Yuki Okushi <[email protected]>
1 parent 1a547f7 commit 4470641

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/tests/adding.md

+14-4
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,25 @@ rough heuristics:
2929
- need to run gdb or lldb? use the `debuginfo` test suite
3030
- need to inspect LLVM IR or MIR IR? use the `codegen` or `mir-opt` test
3131
suites
32-
- need to run rustdoc? Prefer a `rustdoc` test
32+
- need to run rustdoc? Prefer a `rustdoc` or `rustdoc-ui` test.
33+
Occasionally you'll need `rustdoc-js` as well.
3334
- need to inspect the resulting binary in some way? Then use `run-make`
34-
- For most other things, [a `ui` (or `ui-fulldeps`) test](#ui) is to be
35-
preferred:
36-
- `ui` tests subsume both run-pass, compile-fail, and parse-fail tests
35+
- Library tests should go in `library/${crate}/tests` (where `${crate}` is
36+
usually `core`, `alloc`, or `std`). Library tests include:
37+
- tests that an API behaves properly, including accepting various types or
38+
having some runtime behavior
39+
- tests where any compiler warnings are not relevant to the test
40+
- tests that a use of an API gives a compile error, where the exact error
41+
message is not relevant to the test. These should have an
42+
[error number] (`E0XXX`) in the code block to make sure it's the correct error.
43+
- For most other things, [a `ui` (or `ui-fulldeps`) test](#ui) is to be preferred:
44+
- [`ui`](#ui) tests subsume both `run-pass`, `compile-fail`, and `parse-fail` tests
3745
- in the case of warnings or errors, `ui` tests capture the full output,
3846
which makes it easier to review but also helps prevent "hidden" regressions
3947
in the output
4048

49+
[error number]: https://doc.rust-lang.org/rustdoc/unstable-features.html#error-numbers-for-compile-fail-doctests
50+
4151
## Naming your test
4252

4353
We have not traditionally had a lot of structure in the names of

0 commit comments

Comments
 (0)