bears/general: Add FileModeBear
Closes https://github.com/coala/coala-bears/issues/2370
For short term contributors: we understand that getting your commits well defined like we require is a hard task and takes some learning. If you look to help without wanting to contribute long term there's no need for you to learn this. Just drop us a message and we'll take care of brushing up your stuff for merge!
Checklist
- [ ] I read the commit guidelines and I've followed them.
- [ ] I ran coala over my code locally. (All commits have to pass individually. It is not sufficient to have "fixup commits" on your PR, our bot will still report the issues for the previous commit.) You will likely receive a lot of bot comments and build failures if coala does not pass on every single commit!
After you submit your pull request, DO NOT click the 'Update Branch' button. When asked for a rebase, consult coala.io/rebase instead.
Please consider helping us by reviewing other peoples pull requests as well:
- pick up any PR at https://coala.io/review
- review it (check https://coala.io/reviewing for more info)
- if you are sure that it needs work, use
corobo mark wip <URL>to get it out of the review queue.
The more you review, the more your score will grow at coala.io and we will review your PRs faster!
Current codecov failure at 99.91% can be ignored - https://travis-ci.org/coala/coala-bears/jobs/561920971 shows the new bear is getting 100% test coverage
It should be possible to get executable bit working correctly on Windows, and this PR cant close the issue without executable support, as executable support is the primary motivation for this bear, and the need to include Windows was a consistent message throughout the comments of the issue.
@jayvdb The bear works fine for Windows (as it only reads the file permissions and doesn't change them), the problem was I couldn't test it properly on Windows since Python can only set read-only flags on it. One way to test this could be to rename the file to the extension .exe which automatically sets the executable flag.
@bkhanale ,
... the problem was I couldn't test it properly on Windows
If you can not test it, you have no way to determine that is works, and you should not attempt to argue that it does work.
I can see a mile away it does not achieve what the issue requested.
No you do not get to create a useless test by renaming files to .exe . That isnt what the issue asked for.
And even ignoring the fact the bear doesnt work, the test method test_x_to_x_permissions on Windows does:
os.chmod(FILE_PATH, stat.S_IXUSR)
os.chmod(FILE_PATH, stat.S_IRUSR)
That is not a test of the bear, it it. That is wrong. Fix it.
https://github.com/coala/coala-bears/pull/2912/files#r294035442 asked you two months ago to document why you were doing that. You havent done that. Why not?
Why are you using custom test logic instead of verify_local_bear? Is there something about this bear which means verify_local_bear doesnt work for any of the tests? If so, why not use self.check_invalidity?
And even ignoring the fact the bear doesnt work, the test method test_x_to_x_permissions on Windows does:
I guess that he did to roll back changes made to the file permissions (which I guess defaults to read permission).
Why are you using custom test logic instead of verify_local_bear? Is there something about this bear which means verify_local_bear doesnt work for any of the tests? If so, why not use self.check_invalidity?
Yep, you can use check_validity wherever you're not checking for the message statements.