-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[functional test] Re-organize functionnal tests directories #5474
[functional test] Re-organize functionnal tests directories #5474
Conversation
By using the message name as directory name when applicable.
Pull Request Test Coverage Report for Build 1541483344
π - Coveralls |
@cdce8p @DanielNoord this is only a first step as there is still a lot of tidying up to do. I'm using the following code. I think we can merge #5474 before #5475 because moving directories will be easier than moving files anyway and applying the norm all at once is time consuming. (It's easier to review this by looking at the functional directory locally, suggestion welcome.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tbh I'm not really a big fan of constantly moving tests around without much benefits. It's already nearly impossible to use Github blame
to see the correct PR and this certainly doesn't help. Furthermore, what really is the point of putting just two files into a directory?
If it were up to me, I would suggest some last
changes and from then on leave them alone.
- Have a basic folder structure by the first letter.
- Every folder after that should only be on a
need
/makes sense
basis. I isn't really an issue to have 100-200 files in a folder. Most IDEs support quick file lookup anyway. - Keep extension tests separate, like they are now (with the
ext
folder).
--
That's also a reason why I suggested to use a separate structure for tests that should be used as examples. #5396 (comment)
--
I do know that you spend quite some time do this, but those are my honest thoughts.
git still permit to blame and use log properly ? For example
We're starting to have a lot of functional tests. Especially since Daniel took on the work of moving the unittest to functional. It's going to become a nightmare to maintain if we can just put functional tests wherever we want with whatever name we want. I don't say we should not be able to, just that there should be an expected location to put a functional tests without having to do a full search on the whole pylint repositories to discover the name of the functional test files. Enforcing that a functional test file exists directly in pytest will prevent us from having to ask for it, the implementer to think about where to put it and comment asking for a better name/location in reviews. It's also possible to have more than one file in the directory corresponding to a message (deprecated-method does for example).
It's an issue to not be able to see all the file in the explorer, not all contributor are super efficient with an IDE. In fact the same argument could be made about very big files. The IDE permits to jump between class definitions and find usage very easily, why bother creating a file per class and packages ? black still burst their big
I agree and I like where the extension are at right now. Wouldn't it be nice if we had a folder for each checkers and then a folder for each message of this checker too ? We could keep a "free for all" section with letter for mixed functional tests alongside it ? |
Technically yes, but that's quite complicated. (Compared to Github)
I basically never navigate the file tree myself. As long as there are tests, the fastest way to find them is to use search, e.g.
That still requires me to know the checker a message belongs to. From my experience, nearly impossible.
That will always happen. I would suggest to update the contributing documentation. (Although I know it isn't always read.) Not strictly requiring a test file to open a PR also lowers the barrier for new contributors. It's much better if we (as maintainers) can help with the tests than not having a patch at all. => I do not believe we should enforce requiring tests!
A good middle ground is necessary. Folder structures that are nested multiple levels deep aren't helpful either. Especially if those only contains one or two files.
I find it much more helpful if the test file itself makes sense. I.e. related issues contained in one file. Enforcing too strict requirements might lead to worse tests overall just to satisfy the pytest check. I've seen this recently were devs wrote worse code just so pylint wouldn't complain. I plan to open an issue for it soon. |
Wouldn't you know which checker the message you're working on come from ? You're modifying it or even creating it.
I think inexperienced contributor will provide a patch, will not launch test locally and then realize that the CI is their MR is red (where the test message could tell them what to do, our ourselves if they don't read why the test fails). Happened to me in black, their CI checks that the changelog is properly formatted for example.
Do you have something in mind ? My concern is that dividing by starting letter is not enough anymore and the sub-folder that start to appear are not well organized as there is no clear rules.
I agree with that opened #5496 to start the discussion. |
I often look for test files to see when messages are supposed to trigger when I come across them in other tests. I agree that the source-checker is not often known. That said, I often use the search function of my IDE to look for these files instead of going through the folder structure.
I'm not sure how this would be implemented, but I can see this becoming problematic with refactoring and smaller bug fixes. For example, with my recent change to the docstring style checker I didn't necessarily have to add a new test although the change was useful. I fear this might become too strict quickly and working with contributors to make them add tests is the better option here (although more time-consuming). |
OK let's not enforce it then. What would be your preferred organization? Currently we have:
We could add a directory for each checker on top of that (so we extend the extension organization to all checkers):
Or a directory for each message in what we currently have (the current MR does that)
|
I would still suggest to leave the existing tests as is. For new tests, I would say it's enough if it loosely makes sense. When in doubt, I would create a new test file named after the check itself. For example the test for I would also recommend to bump the max number of test files allowed in a folder. |
As this is on the Personally I'm not a big fan of multiple sub-directories in So, I think the current status quo is somewhat "optimal" as it finds a balance between both problems. The question would then be how to formulate the current status quo in the contributing documentation? I'd suggest something like this: Functional tests files should be put in the Some additional notes:
I know you put a lot of time into this @Pierre-Sassoulas but perhaps streamlining the current status quo and guiding users into using the current structure could be a good compromise for all here. |
OK, what about an enforced rule that if a directory exists inside a first level one letter name, all file name must start by the directory name and all file that start with this word must be in this directory ? |
I'm not sure what you mean with "all file name must start by the directory name"? |
Say you have a file called |
Agreed! I think this is a change/fix that we can indeed do, as those files are indeed incorrectly placed. I think the biggest problem with what I proposed is deciding when to add that |
When there are 5 files or more starting by |
Makes sense. That's easily translatable to a directive for the contributing guidelines. |
I like your suggestion @DanielNoord! The script to enforce the current structure would be a nice to have, but certainly not a release blocker for `2.13Β΄. Everything else is probably best done in a new PR / issue. Should we close the PR then? |
Type of Changes
Description
By using the message name as directory name when applicable.
Inspired by #5396