Skip to content

reconsider "the way to run a crate's unit tests is x test <crate>" #140478

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

Open
jyn514 opened this issue Apr 29, 2025 · 2 comments
Open

reconsider "the way to run a crate's unit tests is x test <crate>" #140478

jyn514 opened this issue Apr 29, 2025 · 2 comments
Labels
C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@jyn514
Copy link
Member

jyn514 commented Apr 29, 2025

Summary

@ChrisDenton brought up to me the following thorny problem:

Say you are a libs contributor working on std. Right now, to run all relevant tests, the command you need is something like x test library tests/ui/std rustdoc-js-std. This is verbose and a little unreasonable to expect people to remember.

We would like to add an alias for this; x test std-tests could work. But now x test std does something people don't expect (only runs a subset of the std tests). If we change x test std to mean x test std-tests, then now we have an inconsistency between x test core, which only runs crate tests, and x test std, which means "run a superset of crate tests".

When I added unit tests in #95503, I wasn't really thinking about "run all the tests for an area", because we didn't have any equivalent of std-tests, then or now. But now that I've added it, the naming conflict is unfortunate. Maybe we should reconsider the naming here, and have the way to run unit tests for a crate be x test std-unit or something like that? Or only do this for library crates, and have x test rustc_resolve continue to mean "run the unit tests for rustc_resolve"? It could be nice to have x test rustc_resolve also imply x test tests/ui/resolve, though.

Command used

x test std
x test library
x test rustc_resolve

Expected behaviour

Actual behaviour

Bootstrap configuration (bootstrap.toml)

see above

Operating system

ubuntu 22.04, but this is a problem on all OSes

HEAD

a114bcf

@jyn514 jyn514 added C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Apr 29, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 29, 2025
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 29, 2025
@lolbinarycat
Copy link
Contributor

I was just having this same thought recently, except with rustdoc, where the problem is even worse, due to how many test suites are involved.

@kpreid
Copy link
Contributor

kpreid commented Apr 29, 2025

Speaking as an occasional contributor who hasn't learned all the corners of the codebase, it would be nice to have both of the following readily available:

  • Run all tests in this directory
  • Run all tests of the code in this directory

Perhaps exactly this distinction could be specified with a syntax, and an error produced when it's ambiguous:

./x test in:library/std   # explicit
./x test of:library/std   # explicit
./x test library/std      # error: ambiguous
./x test tests/ui/typeck  # unambiguous

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

No branches or pull requests

5 participants