Skip to content

Add a ratchet for moving all standard library tests to separate packages #144399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 28, 2025

Conversation

bjorn3
Copy link
Member

@bjorn3 bjorn3 commented Jul 24, 2025

#136642 is the previous PR in this series. See #135937 for the rationale of wanting to move all standard library tests to separate packages.

This also fixes std_detect testing on riscv.

bjorn3 added 3 commits July 24, 2025 09:14
Make it clearer where unit tests are allowed and restrict standard
library unit tests inside the same package to std_detect, std and test.
* Fix riscv testing. Previously the mod tests; would be looking for
  src/detect/os/tests.rs.
* Replace a test with an unnamed const item. It is testing that no
  warnings are emitted. It doesn't contain any checks that need to run
  at runtime. Replacing the test allows removing the tidy:skip directive
  for test locations.
@rustbot
Copy link
Collaborator

rustbot commented Jul 24, 2025

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-tidy Area: The tidy tool S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 24, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 24, 2025

There are changes to the tidy tool.

cc @jieyouxu

@Mark-Simulacrum
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 27, 2025

📌 Commit b481c5b has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 27, 2025
bors added a commit that referenced this pull request Jul 28, 2025
Rollup of 7 pull requests

Successful merges:

 - #144072 (update `Atomic*::from_ptr` and `Atomic*::as_ptr` docs)
 - #144151 (`tests/ui/issues/`: The Issues Strike Back [1/N])
 - #144300 (Clippy fixes for miropt-test-tools)
 - #144399 (Add a ratchet for moving all standard library tests to separate packages)
 - #144472 (str: Mark unstable `round_char_boundary` feature functions as const)
 - #144503 (Various refactors to the codegen coordinator code (part 3))
 - #144530 (coverage: Infer `instances_used` from `pgo_func_name_var_map`)

r? `@ghost`
`@rustbot` modify labels: rollup
//!
//! `core` and `alloc` cannot be tested directly due to duplicating lang items.
//! All tests and benchmarks must be written externally in
//! `{coretests,alloctests}/{tests,benches}`.
//!
//! Outside of `core` and `alloc`, tests and benchmarks should be outlined into
//! separate files named `tests.rs` or `benches.rs`, or directories named
//! Outside of the standard library, tests and benchmarks should be outlined
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this say "inside"? If not, I am very confused why this comment gives advice for how to write non-standard-library tests...

Also, what should I do if my test needs access to private functions or fields? Making them all unstably public seems pretty hacky.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outside of the standard library (so eg inside the compiler), tests should be in separate files. These should generally be submodules of the module that you want to test and thus have access to private functions and fields.

Inside the standard library, tests should be not just in separate files, but also in separate packages. Once all standard library tests have actually been moved to separate packages, we can get rid of all lib.miri.rs and testing will become less fragile.

@bors bors merged commit 21120e2 into rust-lang:master Jul 28, 2025
10 checks passed
@rustbot rustbot added this to the 1.90.0 milestone Jul 28, 2025
rust-timer added a commit that referenced this pull request Jul 28, 2025
Rollup merge of #144399 - bjorn3:stdlib_tests_separate_packages, r=Mark-Simulacrum

Add a ratchet for moving all standard library tests to separate packages

#136642 is the previous PR in this series. See #135937 for the rationale of wanting to move all standard library tests to separate packages.

This also fixes std_detect testing on riscv.
@bjorn3 bjorn3 deleted the stdlib_tests_separate_packages branch July 28, 2025 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tidy Area: The tidy tool S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants