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

Split up core/test/iter.rs into multiple files #76391

Merged
merged 4 commits into from
Jan 23, 2021
Merged

Conversation

danii
Copy link
Contributor

@danii danii commented Sep 5, 2020

This PR removes the // ignore-tidy-filelength at the top of iter.rs by splitting it into several sub files. I have split the file per test, based on what I felt the test was really trying to test.
Addresses issue #60302.

  • associated_util.rs - For testing the module level functions. (Maybe should be renamed?)
  • collection.rs - For testing methods that use the values of all the items in an iterator, and creates one value from them, whether it be a Vec of all the values, or a number that represents the sum.
  • mod.rs - For utility structs used in all tests, and other tests I didn't know where to place.
  • range.rs - For testing ranges.
  • transformation.rs - For testing methods that transform all the values in an iterator.
  • util.rs - For testing methods that provide utility in more specific use cases.

"Programatically"

You may have noticed I "Programatically" split up the file. This is how I managed to do that. 😛 Hope that's fine.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 5, 2020
@jyn514 jyn514 added the C-cleanup Category: PRs that clean code up or issues documenting cleanup. label Sep 5, 2020
@jyn514 jyn514 changed the title Split Up Files With ignore-tidy-filelength Split up core/test/iter.rs into multiple files Sep 5, 2020
@jyn514 jyn514 added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 5, 2020
@danii danii marked this pull request as ready for review September 7, 2020 21:08
@jyn514 jyn514 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. A-testsuite Area: The testsuite used to check the correctness of rustc and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 7, 2020
@Mark-Simulacrum
Copy link
Member

r? @cuviper who has done a lot with iterators so is likely better able to gauge if this splitting is the right one or even helpful :)

@cuviper
Copy link
Member

cuviper commented Sep 16, 2020

I'm fine with the idea of splitting this up, but the current subdivisions don't make much sense to me. The rough principal I would use is how easy someone could guess where to find related test cases. Like, suppose I just fixed something in Chain, then is it obvious where I would find tests focused on chain? (Hopefully they're together!)

(At the end of the day, this will all be very subjective, but it's also just tests -- not an API we have to commit to.)

This group seems fine, but I'd probably just call it functions.rs.

  • collection.rs - For testing methods that use the values of all the items in an iterator, and creates one value from them, whether it be a Vec of all the values, or a number that represents the sum.

There's one test_collect that's on the nose, but the rest of these don't make sense to me. There are tests of folds, sums, products, min/max -- I would not have thought to look in collection.rs for any of these.

  • mod.rs - For utility structs used in all tests, and other tests I didn't know where to place.

That's fine for mod.rs to be the default catch-all for tests, but I wouldn't bother with the mod other nesting. As for the utility structs, I think they only belong here if they would be shared by multiple different test modules, otherwise keep them close to their tests so it's clear what those are doing.

This one is good, they're all range iterators.

  • transformation.rs - For testing methods that transform all the values in an iterator.

This is ambiguous to me -- I wouldn't guess what to find in there, and it looks like quite a mix.

  • util.rs - For testing methods that provide utility in more specific use cases.

This too, I find unintuitive.

I guess the point is that I don't really care what a test is doing, since they are usually invented scenarios that aren't the point. What matters is to group them by what they are testing. If I modify Chain or Zip, I want to find all the tests centered around that particular iterator. Stuff like min/max and maybe eq/lt/etc. can go together, but I would make it obvious like ordering.rs.

I think it's fine if these end up even smaller, rather than trying to define very broad groups. If it's too small (subjective), just leave it at the top level.

@cuviper
Copy link
Member

cuviper commented Sep 16, 2020

You could just mirror the layout of core/src/iter/, so the subjective organization is already decided for you, assuming you can figure out the focus of each particular test.

@bors
Copy link
Contributor

bors commented Sep 19, 2020

☔ The latest upstream changes (presumably #76912) made this pull request unmergeable. Please resolve the merge conflicts.

Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@danii
Copy link
Contributor Author

danii commented Sep 25, 2020

I've taken your suggestion to mirror the layout of core/src/iter to heart, and have decided to resort everything in fns.txt to programatically split it again.
Do you mind reviewing my fns.txt in case there's any other big changes you want me to make?
Format of fns.txt is simple, <resulting file> fn <function name in iter.rs> for each line.
Yes, those file names do include ::, but I'll move them manually into the right folders and rename them afterwards.

I have tried to mirror it as close as I can, but it did get fuzzy. I decided to put tests relating to a trait or an adapter in the module corresponding to it. I also decided to add new modules for some things if they ended up in the modules core::iter::traits and core::iter::adapters (excluding submodules). If you'd like, I can remove those extra submodules.

I feel this is definitely a lot better from my first attempt, because they aren't split into broad groups anymore, and it did feel like that was a bit of an issue. :)

@cuviper
Copy link
Member

cuviper commented Oct 3, 2020

Do you mind reviewing my fns.txt in case there's any other big changes you want me to make?

This seems to be gone now, 404.

@danii
Copy link
Contributor Author

danii commented Oct 9, 2020

Oh oops, I recently changed my name...
https://gist.github.com/danii/a58b3bcafa9faf1c3e4b01ad7495baf4
Surprised that doesn't temporarily redirect like repository links.

@camelid camelid added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 30, 2020
@cuviper
Copy link
Member

cuviper commented Nov 3, 2020

@danii That breakdown looks good to me!

@crlf0710
Copy link
Member

@danii Ping from triage, this seems need a rebase to continue. Would you mind doing so? Thanks!

@JohnCSimon JohnCSimon added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 7, 2020
@danii
Copy link
Contributor Author

danii commented Jan 9, 2021

@rustbot label -S-waiting-on-author +S-waiting-on-review

After a season, this should be ready to rebase, I hope.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 9, 2021
@bors
Copy link
Contributor

bors commented Jan 14, 2021

☔ The latest upstream changes (presumably #81018) made this pull request unmergeable. Please resolve the merge conflicts.

@bors
Copy link
Contributor

bors commented Jan 22, 2021

☔ The latest upstream changes (presumably #81152) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Member

@cuviper cuviper left a comment

Choose a reason for hiding this comment

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

It's difficult to be sure that nothing is lost, but I'm concerned that the net line count is reduced:

33 files changed, 3574 insertions(+), 3681 deletions(-)

If anything, I'd expect it to increase for the repetition of use statements in each new file. At least some of the loss will be simple whitespace between functions though, which I would like to see fixed.

library/core/tests/iter/adapters/chain.rs Show resolved Hide resolved
library/core/tests/iter.rs Show resolved Hide resolved
library/core/tests/iter.rs Show resolved Hide resolved
library/core/tests/iter/adapters/map.rs Outdated Show resolved Hide resolved
library/core/tests/iter/adapters/map.rs Outdated Show resolved Hide resolved
library/core/tests/iter/mod.rs Outdated Show resolved Hide resolved
library/core/tests/iter/traits/double_ended.rs Outdated Show resolved Hide resolved
library/core/tests/iter/traits/double_ended.rs Outdated Show resolved Hide resolved
library/core/tests/iter/traits/marker.rs Outdated Show resolved Hide resolved
library/core/tests/iter/traits/mod.rs Outdated Show resolved Hide resolved
@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
configure: rust.channel         := nightly
configure: rust.debug-assertions := True
configure: llvm.assertions      := True
configure: dist.missing-tools   := True
configure: build.configure-args := ['--enable-sccache', '--disable-manage-submodu ...
configure: writing `config.toml` in current directory
configure: 
configure: run `python /checkout/x.py --help`
configure: 
---
    Checking std v0.0.0 (/checkout/library/std)
error[E0583]: file not found for module `step`
  --> library/core/tests/iter/adapters/mod.rs:18:1
   |
18 | mod step;
   |
   |
   = help: to create the module `step`, create file "library/core/tests/iter/adapters/step.rs"
error: aborting due to previous error

For more information about this error, try `rustc --explain E0583`.
error: could not compile `core`
error: could not compile `core`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "check" "--target" "i686-pc-windows-gnu" "-Zbinary-dep-depinfo" "-j" "16" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace compiler-builtins-c" "--manifest-path" "/checkout/library/test/Cargo.toml" "--all-targets" "-p" "test" "-p" "std" "-p" "unwind" "-p" "alloc" "-p" "proc_macro" "-p" "panic_abort" "-p" "core" "-p" "panic_unwind" "-p" "term" "--message-format" "json-render-diagnostics"
failed to run: /checkout/obj/build/bootstrap/debug/bootstrap check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu --all-targets
Build completed unsuccessfully in 0:00:40

Copy link
Member

@cuviper cuviper left a comment

Choose a reason for hiding this comment

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

Looks great, thanks! The added documentation is very welcome too.

@cuviper
Copy link
Member

cuviper commented Jan 23, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Jan 23, 2021

📌 Commit 0c78500 has been approved by cuviper

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 23, 2021
@danii
Copy link
Contributor Author

danii commented Jan 23, 2021

Ay, nice! I know I sat on this pull request for too long, but now I'm feeling great. Thank you.

@bors
Copy link
Contributor

bors commented Jan 23, 2021

⌛ Testing commit 0c78500 with merge fe0fa59...

@bors
Copy link
Contributor

bors commented Jan 23, 2021

☀️ Test successful - checks-actions
Approved by: cuviper
Pushing fe0fa59 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 23, 2021
@bors bors merged commit fe0fa59 into rust-lang:master Jan 23, 2021
@rustbot rustbot added this to the 1.51.0 milestone Jan 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc C-cleanup Category: PRs that clean code up or issues documenting cleanup. merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.