safer icon indicating copy to clipboard operation
safer copied to clipboard

Fix Failing Tests on Windows (WIP)

Open Chiemezuo opened this issue 1 year ago • 6 comments

This is in line with #8

I'm working on getting the test cases to pass for Windows.

Upon installation, 6 of the 70 existing tests were failing. Here's a short summary of them:

=================================================== short test summary info =================================================== 
FAILED test/test_open.py::TestSafer::test_file_perms - AssertionError: -rw-rw-rw-
FAILED test/test_open.py::TestSafer::test_symlink_directory - OSError: [WinError 1314] A required privilege is not held by the client: 'sub' -> 'sub.sym'
FAILED test/test_open.py::TestSafer::test_symlink_file - OSError: [WinError 1314] A required privilege is not held by the client: 'one' -> 'one.sym'
FAILED test/test_open.py::TestSafer::test_tempfile_perms - assert 33206 in (33188, 33204)
FAILED test/test_writer.py::test_wrapper_bug2 - PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\...
FAILED test/test_writer.py::test_wrapper_bug3 - PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\...

Fixed tests

  • [x] test_file_perms
  • [x] test_symlink_directory
  • [x] test_symlink_file
  • [x] test_temlpfile_perms
  • [x] test_wrapper_bug2
  • [x] test_wrapper_bug3

Summary by Sourcery

Bug Fixes:

  • Fix the test_file_perms test to handle file permission checks correctly on Windows by adjusting the logic to account for Windows-specific file handling.

Chiemezuo avatar Oct 22 '24 13:10 Chiemezuo

Reviewer's Guide by Sourcery

This pull request addresses failing tests on Windows platforms, focusing on file permission and symlink-related issues. The changes primarily involve modifying the test suite to account for differences in file handling between UNIX and Windows systems.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Modify file permission checks in test cases to accommodate Windows
  • Add conditional logic to handle file permission checks differently on Windows
  • Replace specific permission bit checks with a more general file type check on Windows
  • Retain original UNIX-specific permission checks for POSIX systems
test/test_open.py
Address symlink-related test failures on Windows
  • Identify symlink creation issues due to privilege restrictions on Windows
  • Mark symlink-related tests as failing and needing further investigation
test/test_open.py
Investigate file access issues in wrapper-related tests
  • Identify PermissionError occurrences in wrapper bug tests
  • Mark wrapper-related tests as failing and needing further investigation
test/test_writer.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in the pull request body to generate a PR summary at any time. You can also use this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

  • Contact our support team for questions or feedback.
  • Visit our documentation for detailed guides and information.
  • Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.

sourcery-ai[bot] avatar Oct 22 '24 13:10 sourcery-ai[bot]

@rec The symlink directory and files tests will work only on the condition that the tests are being run in a terminal that contains admin privileges. Unfortunately, admin privileges are not given to terminals by default (but can be changed). I set the test to skip for Windows if admin privileges are not given (instead of failing), but they will pass if given (or will fail if the source of errors is not from privileges).

Chiemezuo avatar Oct 22 '24 17:10 Chiemezuo

Looks good for another round of reviews

PS: I'll look deeper into the Windows-y command.

Chiemezuo avatar Oct 25 '24 07:10 Chiemezuo

So it's very natural to demonstrate that you comprehend and are keeping up, but a magic secret to appearing to be a more senior programmer is only talking about operative or actionable questions.

Overall, you don't need to respond to comments if you agree with them, or say what you are going to do, unless there's a question! :-D (Also, you should use the review feature to group together comments in one email, not that it's a big deal, particularly with such a small project.)

Computer programming is a very noisy occupation so I spend extra care in only sending people messages which are actionable, i.e., ask them to do something, or ask a question, or give them information they asked for.

Otherwise, people simply miss stuff in the traffic.

This also leaves more time for actual chat. 🔈

As I said, it's extremely natural, so don't think it's some sort of sin. Mostly you discover this somewhat later, when you have multiple junior programmers each trying to out-volume the other in progress reports... 😈

rec avatar Oct 25 '24 10:10 rec

@rec A pending workflow approval

Chiemezuo avatar Oct 31 '24 13:10 Chiemezuo

Voila: https://github.com/rec/safer/pull/28

I'll add you as a reviewer once you've accepted my invitation on this repo...

rec avatar Nov 02 '24 13:11 rec