Skip to content

Conversation

@DimitriPapadopoulos
Copy link
Collaborator

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.

@DimitriPapadopoulos
Copy link
Collaborator Author

I'm puzzled by this test:

assert cs.main('--skip=*ignoredir/bad*', d) == 1

Is *ignoredir/bad* really supposed to match tempdir/ignoredir/subdir/bad.txt?

@peternewman
Copy link
Collaborator

I'm puzzled by this test:

assert cs.main('--skip=*ignoredir/bad*', d) == 1

Is *ignoredir/bad* really supposed to match tempdir/ignoredir/subdir/bad.txt?

No, the old/current code actually generates:
tempdir/ignoredir/bad.txt

But the fact it passes shows how bad the current skip matching is!

Comment on lines 296 to 297
│   └── subdir
│    └── bad.txt
Copy link
Collaborator

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:

Suggested change
│   └── subdir
│    └── bad.txt
│ └── bad.txt

Do we need another level to test some more edge cases?

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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/path in addition to --skip=./my/path when codespell is called on the current directory
  • skip absolute paths when codespell is called on a relative path, for example handle --skip=/absolute/path when codespell is called on a relative path (probably the least important issue)

Copy link
Collaborator

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?

Copy link
Collaborator

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/path in addition to --skip=./my/path when codespell is called on the current directory
  • skip absolute paths when codespell is called on a relative path, for example handle --skip=/absolute/path when codespell is called on a relative path (probably the least important issue)

Sounds good.

Copy link
Collaborator Author

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...

Copy link
Collaborator

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?

Copy link
Collaborator

@peternewman peternewman Jan 7, 2022

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!

@DimitriPapadopoulos DimitriPapadopoulos force-pushed the extensive_test_ignore branch 3 times, most recently from f6940c6 to 5ee5792 Compare January 7, 2022 17:37
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
Copy link
Collaborator

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 😆 .

@DimitriPapadopoulos
Copy link
Collaborator Author

I have mistakenly erased this branch. Need to rewrite it, taking into account your remarks. Sorry.

@peternewman
Copy link
Collaborator

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:

bad
1bad
bad1

So we know it's not matched the files/folders we didn't intend to match.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants