Tracking Issue for ui test suite improvements · Issue #133895 · rust-lang/rust (original) (raw)

This is a tracking issue for an initiative of improving ui test suite organization and ui test usability. This issue is not meant for general discussions, but is instead intended for tracking logistics of PRs. For specific matters, please discuss in the zulip thread https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Discussion.20for.20ui.20test.20suite.20improvements.

Tip

I'm happy to mentor and review work that contributes towards this initiative. You could select a few non-descriptive ui tests (see below for criteria) to improve (max ~5-7 tests in a batch) and r? jieyouxu on the PR.

Please don't claim this issue; it's intended to be available to be worked by multiple contributors.

Context

The ui test suite (tests/ui/) has a lot of tests. Often, many ui tests suffer from:

Possible improvements

The guiding rationale for improving ui test usability is to:

  1. Make it easier to figure out test intention:
    1. What the test intends to check.
    2. What are the relevant context (issues, PRs, discussions, RFCs) or areas.
  2. Make it easier to find tests. E.g. keywords, better directory organizations, better test names.
  3. Don't regress existing ui test coverage: for example, if a parser test relies on specific formatting, do not rustfmt the test as it will regress test coverage.

See Best practices for writing tests in rustc-dev-guide for advice on how to make ui tests more useful. However, don't take the advice at face value -- they should be evaluated on a case-by-case basis. For instance, some subdirectory might contain a collection of specific regression tests related to issues, and in that case having tests be named just issue-xxxxx.rs isn't bad. On the contrary, a top-level issue-xxxxx.rs under tests/ui/ is not very informative.

Example of things that might be done, but only if it makes sense on a case-by-case basis:

Because these require discretion (changes are not always improvements!), this issue is labeled E-medium and not just E-easy. Having "insider" compiler implementation knowledge helps a lot here.

Example test doc comment

No fixed format, adapt as suitable for the test at hand. But an example:

//! Check that -A warnings cli flag applies to all warnings, including feature gate warnings. //! //! This test tries to exercise that by checking that the "empty trait list for derive" warning for //! #[derive()] is permitted by -A warnings, which is a non-lint warning. //! //! # Relevant context //! //! - Original impl PR: https://github.com/rust-lang/rust/pull/21248. //! - RFC 507 "Release channels": //! https://github.com/rust-lang/rfcs/blob/c017755b9bfa0421570d92ba38082302e0f3ad4f/text/0507-release-channels.md.

Long-term plan

  1. Reorganize all the stray tests immediately under tests/ui and place them into suitable subdirectories, improving the tests themselves along the way.
  2. Review and audit the immediate subdirectories under tests/ui/, and see if they need to be fusioned/fissioned/renamed or otherwise adjusted. Where suitable, we can also introduce some subdirectory-level README.md to document subdirectory intention/area.
  3. Kill off generic tests/ui/issues/ directory and rehome the tests properly.

Implementation history

Note: these are some of the earlier PRs (so not necessarily exhaustive), I may stop updating this listing if we have more PRs. Writing "Part of #133895" will cause the PR to still show-up via backlinks.

  1. not always problematic! Requires discretion.