-
Notifications
You must be signed in to change notification settings - Fork 506
Add many tests for --skip
#2227
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
Add many tests for --skip
#2227
Conversation
|
I'm puzzled by this test: codespell/codespell_lib/tests/test_basic.py Line 308 in bdcf7a6
Is |
No, the old/current code actually generates: But the fact it passes shows how bad the current skip matching is! |
codespell_lib/tests/test_basic.py
Outdated
| │ └── subdir | ||
| │ └── bad.txt |
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.
So the current is this:
| │ └── subdir | |
| │ └── bad.txt | |
| │ └── bad.txt |
Do we need another level to test some more edge cases?
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.
I'd rather put bad.txt under subdir (which I was certain it was 😃) to get that extra level.
I believe that would catch all possible errors.
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.
This time I've really changed the file hierarchy to:
tmpdir
├── good.txt
├── bad.txt
├── ignoredir
│ └── subdir
│ └── bad.txt
└── bad.js
I think we have enough tests to proceed with the changes without regressions.
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.
The current skip matching isn't that bad. The 3 main issues are:
- handle
--skip=ignoredir/with a trailing/ - skip relative paths when codespell is called on a relative path, for example handle
--skip=my/pathin addition to--skip=./my/pathwhen codespell is called on the current directory - skip absolute paths when codespell is called on a relative path, for example handle
--skip=/absolute/pathwhen codespell is called on a relative path (probably the least important issue)
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.
Do we want another bad.txt in ignoredir too?
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.
The current skip matching isn't that bad.
Yeah I think it was actually just your tofix labelling. 😄
The 3 main issues are:
- handle
--skip=ignoredir/with a trailing/- skip relative paths when codespell is called on a relative path, for example handle
--skip=my/pathin addition to--skip=./my/pathwhen codespell is called on the current directory- skip absolute paths when codespell is called on a relative path, for example handle
--skip=/absolute/pathwhen codespell is called on a relative path (probably the least important issue)
Sounds good.
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.
We could add a bad.txt in the 1st level subdirectory. However, we know when we have succeeded ignoring ignnoredir because ignnoredir/subdir/bad.txt will be ignored too. Furthermore, if ignoring a file works both for bad.txt in the top directory and ignoredir/subdir/bad.txt in the 2nd level subdirectory, I think testing in the 1st level subdirectory too is far-fetched. We could do that of course, but then why not test a 3rd level, and a 4th level, and...
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.
Although we can't currently do ignoredir/subdir test can we? To prove it doesn't hit/miss the one within ignoredir?
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.
We probably also want another file in the subdirectories, maybe with another typo, or unique typos per file or something, so we can confirm we aren't just ignoring everything in ignoredir/subdir when we are just trying to block bad.txt within there.
Actually the clever thing might be to have a different power of two number of typos in each different test file, then we know we've got ignored exactly the files we planned to!
f6940c6 to
5ee5792
Compare
codespell_lib/tests/test_basic.py
Outdated
| assert cs.main(d) == 2 | ||
| assert cs.main('--skip=bad*', d) == 0 | ||
| assert cs.main('--skip=*ignoredir*', d) == 1 | ||
| assert cs.main('--skip=*ad*', d) == 0 |
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.
Sort of the same with this, if it's actually gone wrong and just matched *, we'd be none the wiser.
Perhaps bad and badder 😆 .
5ee5792 to
d71cdc3
Compare
|
I have mistakenly erased this branch. Need to rewrite it, taking into account your remarks. Sorry. |
Oops. We should probably also have some files and folders like: So we know it's not matched the files/folders we didn't intend to match. |
These tests shows what needs to be fixed in the current implementation and will help avoid regressions while fixing.
Will help test and review #2058.