Skip to content

Various improvements for test output#6822

Open
matthewhughes934 wants to merge 4 commits into
rust-lang:mainfrom
matthewhughes934:misc-fixes
Open

Various improvements for test output#6822
matthewhughes934 wants to merge 4 commits into
rust-lang:mainfrom
matthewhughes934:misc-fixes

Conversation

@matthewhughes934
Copy link
Copy Markdown
Contributor

@matthewhughes934 matthewhughes934 commented Mar 7, 2026

The main focus on this changeset is to reduce some noise that was
annoying me in test output (particularly in test failures)

There are still some compile errors outputted during tests (on failure
or with --nocapture due to doctests with compile_fail (there's an
open issue about this[1])

Link: rust-lang/rust#55813 [1]

  • Update docs for Session.format

    To stop referencing parameters out and config that were both moved
    into the Session object with 71d3d04

  • Move stray imports_granularity test

    Move this to be with all the other tests for this config option

  • Silence expected parser errors

    I find otherwise the test output can be a bit noisy, and in particular
    the error messages make me think some test somewhere failed when even
    when it's all passing, for example, one such removed error:

      error: mismatched closing delimiter: `}`
       --> tests/parser/unclosed-delims/issue_4466.rs:3:17
        |
      2 |     if true {
        |             - closing delimiter possibly meant for this
      3 |         println!("answer: {}", a_func();
        |                 ^ unclosed delimiter
      4 |     } else {
        |     ^ mismatched closing delimiter
    

    This also removes some noisy warnings like:

      warning: whitespace symbol '\u{a0}' is not skipped
       --> tests/target/string_lit_unicode_ws.rs:3:22
        |
      3 |       let str = "hello \
        |  ______________________^
      4 | |  world";
        | | ^ whitespace symbol '\u{a0}' is not skipped
        | |_|
        |
    
  • Remove warning on explicit default config value in tests

    This was added with f7a25a1, this was
    to address an issue with the worthy goal[1]:

    It is probably worth auditing the tests and where they are not
    deliberately testing an option, removing any options they set.

    However, given the number of warnings this produces:

    $ cargo test -- --nocapture |& grep -c 'Default value.*used explicitly'
    236
    

    I think this approach did not work, one could enforce this approach by
    changing this to be an error, but I think there are valid cases to use
    defaults, e.g. a reproduction of an issue relating to line length uses
    the default max_width: it's simplest to add a test verifying the
    behaviour with an explicit max_width: 100 rather than adjusting the
    reproduction.

    Link: improve test coverage for defaults #1720 [1]

@rustbot rustbot added the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label Mar 7, 2026
@ytmimi
Copy link
Copy Markdown
Contributor

ytmimi commented Mar 8, 2026

r? @ytmimi

To stop referencing parameters `out` and `config` that were both moved
into the `Session` object with 71d3d04
Move this to be with all the other tests for this config option
I find otherwise the test output can be a bit noisy, and in particular
the error messages make me think some test somewhere failed when even
when it's all passing, for example, one such removed error:

    error: mismatched closing delimiter: `}`
     --> tests/parser/unclosed-delims/issue_4466.rs:3:17
      |
    2 |     if true {
      |             - closing delimiter possibly meant for this
    3 |         println!("answer: {}", a_func();
      |                 ^ unclosed delimiter
    4 |     } else {
      |     ^ mismatched closing delimiter

This also removes some noisy warnings like:

    warning: whitespace symbol '\u{a0}' is not skipped
     --> tests/target/string_lit_unicode_ws.rs:3:22
      |
    3 |       let str = "hello \
      |  ______________________^
    4 | |  world";
      | | ^ whitespace symbol '\u{a0}' is not skipped
      | |_|
      |
This was added with f7a25a1, this was
to address an issue with the worthy goal[1]:

> It is probably worth auditing the tests and where they are not
deliberately testing an option, removing any options they set.

However, given the number of warnings this produces:

  $ cargo test -- --nocapture |& grep -c 'Default value.*used explicitly'
  236

I think this approach did not work, one could enforce this approach by
changing this to be an error, but I think there are valid cases to use
defaults, e.g. a reproduction of an issue relating to line length uses
the default `max_width`: it's simplest to add a test verifying the
behaviour with an explicit `max_width: 100` rather than adjusting the
reproduction.

Link: rust-lang#1720 [1]
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 26, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants