-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
Conversation
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 has assigned @Mark-Simulacrum. Use |
There are changes to the cc @jieyouxu |
@bors r+ |
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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.
#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.