Skip to content
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

Test refactor #1019

Merged
merged 11 commits into from
Jul 16, 2019
Merged

Test refactor #1019

merged 11 commits into from
Jul 16, 2019

Conversation

Thomasdezeeuw
Copy link
Collaborator

Step one refactoring the tests.

This

  • removes the test_ prefix from the test files,
  • renames the test directory to tests, and
  • merges some test files.

The easiest way to review is to do it per commit as I tried to make small(ish) logical changes per commit. But combined they become rather big.

No change were functionally changed or removed.

Updates #995.

Copy link
Member

@carllerche carllerche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I find smaller test files easier to manage, but I'm fine going this route if you want.

@asomers
Copy link
Collaborator

asomers commented Jul 9, 2019

The old setup compiled everything in the test directory into a single executable. But your PR results in several different executables. I find it harder to understand the output of "cargo test" when there are several executables in the tests directory.

@carllerche
Copy link
Member

@asomers this is the idiomatic way to do it w/ rust & cargo now (mio predates all this). could you elaborate more on what you find harder to understand?

@Thomasdezeeuw
Copy link
Collaborator Author

@asomers I agree that the multiple lists of tests vs 1 single list of tests is somewhat harder to read, but as @carllerche mentioned it's the way to do it in Rust now. It's also the reason why I merged some of the files to reduce the number of lists of tests.

@asomers
Copy link
Collaborator

asomers commented Jul 9, 2019

For one thing, there's a lot more output this way. For another, it's hard to see how many test cases there are in total. And finally, it's harder to see the difference between tests, lib tests, and doc tests in the output.

@Thomasdezeeuw
Copy link
Collaborator Author

@asomers I agree. We can reduce the number of files and thus binaries and sections of tests to make the output a bit more manageable. cargo test -- --format terse can also be used, which replaces each test name with a single dot, doesn't make the output much clearer but it does become shorter.

@carllerche
Copy link
Member

What's the conclusion?

@Thomasdezeeuw
Copy link
Collaborator Author

I've looking making the output more usable and found some issues: rust-lang/cargo#4324, rust-lang/cargo#2832. Basically other people have the same problem but no one improved the situation yet.

But I believe this is still the way to go.

@carllerche
Copy link
Member

@asomers You ok to proceed?

@asomers
Copy link
Collaborator

asomers commented Jul 10, 2019

@Thomasdezeeuw how do you feel about moving files into a subdirectory? That would still keep the files separate but reduce the number of binaries. The file structure would look like this:

tests/
    functional/
        mod.rs
        interests.rs
        poll.rs
        ....

This is the direction I'm moving for my crates, to minimize the number of binaries. It still allows separate test binaries when that's really called for. For example, nix has a few dedicated binaries for tests that don't use the standard test harness, or that must run in their own process for some other reason.

@carllerche
Copy link
Member

@asomers I'm not disagreeing that there are issues w/ the idiomatic structure. My personal take is that I don't want to go against the grain here. I'd like mio to just follow idiomatic cargo structure and any discussion about alt layouts / improvements taken up w/ cargo.

@Thomasdezeeuw
Copy link
Collaborator Author

@asomers files two layers deep, e.g. tests/functional/poll.rs, won't be turned into tests automatically. We further merge the files for example to tcp.rs, udp.rs (or even merge them into a single net.rs file), poll.rs, event.rs and waker.rs. But them we might end up with very large test files.

@carllerche
Copy link
Member

fwiw, i've always wished we could add dirs to tests... probably another thing to bring up w/ cargo.

@asomers
Copy link
Collaborator

asomers commented Jul 11, 2019

Perhaps tests/functional/mod.rs won't be added automatically (I haven't checked), but tests/functional.rs will, and that can include files from other subdirectories. In any case, it's not worth fighting over. While my preference is for fewer binaries, your change is certainly not wrong, and I won't object if you commit it as is.

@Thomasdezeeuw
Copy link
Collaborator Author

@asomers I've experimented with your idea in #1030, only look at the last commit.

@Thomasdezeeuw
Copy link
Collaborator Author

Following some experimentation in #1030, I'm merging this with the indent to move to the structure @asomers laid out in #1019 (comment), once the rustfmt bugs have been resolved (see #1030).

@Thomasdezeeuw Thomasdezeeuw merged commit ec0f5c9 into tokio-rs:master Jul 16, 2019
@Thomasdezeeuw Thomasdezeeuw deleted the test-refactor branch July 16, 2019 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants