From 8b81c63d6db2f194e37ce104f635a790757c1329 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Thu, 26 Mar 2026 10:07:54 -0400 Subject: [PATCH 1/2] Update information about adding unit tests - Specifically guide new contributors that unit tests for `core` and `alloc` do not belong within those crates and instead belong in the `coretests` and `alloctests` crates. - Also add some information about which `lib.rs` file needs the unstable feature declarations --- src/tests/adding.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/tests/adding.md b/src/tests/adding.md index ebbbb1cfc0..5471900e41 100644 --- a/src/tests/adding.md +++ b/src/tests/adding.md @@ -17,8 +17,12 @@ guidelines: - The majority of standard library tests are written as doctests, which illustrate and exercise typical API behavior. - Additional [unit tests](intro.md#package-tests) should go in - `library/${crate}/tests` (where `${crate}` is usually `core`, `alloc`, or - `std`). + `library/${crate}/tests` (where `${crate}` is usually `std`). + - Tests for the `alloc` or `core` crates must go within their respective + `library/${crate}tests/tests` folder. + - NOTE: That when adding unit tests for unstable features the `#![feature(...)]` + declaration **must** be added to `library/${crate}tests/tests/lib.rs` and not to + `library/${crate}tests/lib.rs`. - If the code is part of an isolated system, and you are not testing compiler output, consider using a [unit or integration test](intro.md#package-tests). - Need to run rustdoc? Prefer a `rustdoc` or `rustdoc-ui` test. Occasionally From cc1685c9ae4e86737cf49aa4b89d7b02a9a22fe2 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Thu, 26 Mar 2026 10:56:35 -0400 Subject: [PATCH 2/2] Tweak wording of adding new tests guide --- src/tests/adding.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/tests/adding.md b/src/tests/adding.md index 5471900e41..10483265c4 100644 --- a/src/tests/adding.md +++ b/src/tests/adding.md @@ -18,10 +18,9 @@ guidelines: illustrate and exercise typical API behavior. - Additional [unit tests](intro.md#package-tests) should go in `library/${crate}/tests` (where `${crate}` is usually `std`). - - Tests for the `alloc` or `core` crates must go within their respective - `library/${crate}tests/tests` folder. + - Tests for the `alloc` or `core` crates must go in separate crates: `alloctests` or `coretests` respectively. - NOTE: That when adding unit tests for unstable features the `#![feature(...)]` - declaration **must** be added to `library/${crate}tests/tests/lib.rs` and not to + declaration must be added to `library/${crate}tests/tests/lib.rs` and not to `library/${crate}tests/lib.rs`. - If the code is part of an isolated system, and you are not testing compiler output, consider using a [unit or integration test](intro.md#package-tests).