Skip to content

cargo fmt doesn't format files in sub-directories in tests #1820

Closed

Description

@steveklabnik

I have a big integration test suite with sub-directories inside of the tests directory; running cargo fmt doesn't format these files.

Activity

  1. added this to the impl period milestone on Sep 18, 2017
  2. brauliobz commented on Sep 27, 2017

    @brauliobz

    cargo fmt only formats test code that is reached by cargo test, which basically follows the mod inclusions, from what I could see.

    I tested the following scenario:

    tests/
        root_test.rs
        subdir/
            mod.rs
            sub_test.rs
    

    sub_test.rs is formatted only when:

    • root_test.rs includes subdir by mod subdir;;
    • and subdir/mod.rs includes sub_test.rs by mod sub_test;.

    Is this behavior really desirable?

  3. nrc commented on Sep 29, 2017

    @nrc
    Member

    I think there are two kinds of cargo test - unit tests, which cargo fmt should reach if they are reachable via module includes (I think this is fine); and integration tests, which are not formatted at all (which we should address, though I'm not really sure how).

  4. removed this from the impl period milestone on Jan 11, 2018
  5. calebcartwright commented on Sep 4, 2019

    @calebcartwright
    Member

    Just a heads up that I've taken a pass at this and now have a working implementation locally.

    Will open a PR for discussion/review/etc. within the next day or two

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P-highHigh priority

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions