-
Notifications
You must be signed in to change notification settings - Fork 97
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
tests(windows): fix remaining "unixisms" that break some tests #816
Conversation
7dc2c44
to
533f876
Compare
4f9ea08
to
5949a1b
Compare
I misunderstood the Python docs and thought I could have |
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 is great! 🎉
Left a few questions and nitpicks, but hopefully easy to fix.
I misunderstood the Python docs and thought I could have WindowsError in the code and that it wouldn't just check, but that actually breaks on Linux as it is undefined. I changed it to the more generic OSError and then a guard to check for the actual error code.
From the docs, WindowsError
also seems to be deprecated since version 3.3, so we should just use OSError
: https://docs.python.org/3/library/exceptions.html#WindowsError.
["--tool", 'cmd.exe /c start ""', "--all", "Krishnamurti"]) | ||
["--tool", "cmd.exe /c type", "--all", "Krishnamurti"]) |
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.
Does "start" not work here? Or?
It raises WinError, an exception that subclasses OSError. WinError can’t be in code that would run on Linux, since that’s undefined. I’ll probably move Windows specific stuff into its own utility function as you suggested so that we have specific WinError exceptions.
As for checking before actually running the operations, I guess that’s not impossible, but where should the check go? After installation, warning the user that functionality would be reduced due to dev mode not enabled, for instance?
Enric Morales ***@***.***>
________________________________
From: Alex Fikl ***@***.***>
Sent: Saturday, April 13, 2024 8:25:06 AM
To: papis/papis ***@***.***>
Cc: Enric Morales ***@***.***>; Author ***@***.***>
Subject: Re: [papis/papis] tests(windows): fix remaining "unixisms" that break some tests (PR #816)
@alexfikl commented on this pull request.
________________________________
In papis/commands/add.py<#816 (comment)>:
+ try:
+ logger.info("[SYMLINK] '%s' to '%s'.", in_file_abspath,
+ tmp_end_filepath)
+ os.symlink(in_file_abspath, tmp_end_filepath)
+ except OSError as e:
+ missing_privilege_error = 1314
+ if sys.platform == "win32" and e.winerror == missing_privilege_error:
+ logger.error("Failed to link due to insufficient permissions. You "
+ "can try again after enabling the 'Developer mode' "
+ "and restarting.")
+ raise
I can't check, but does this throw just a generic OSError? Maybe we can better check for a PermissionError or something to show that message.
—
Reply to this email directly, view it on GitHub<#816 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AADRN4PM2PI473SQRYSQE6DY5DFUFAVCNFSM6AAAAABGEMMQS2VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTSOJZGA2TOOBRGI>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
According to the docs,
I was just thinking for that specific test, to just add a little
But it was mostly for curiosity. They way it is now is just fine! |
|
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.
Left a few more suggestions, but this should be good to go once we can use the git stuff from #810.
This happens on a new Windows installation
papis/commands/mv.py
Fixed
papis.utils.run((["git"] if git else []) + ["mv", folder, new_folder_path], | ||
cwd=folder) | ||
if git: | ||
papis.git.mv_and_commit_resource(folder, new_folder_path) |
Check failure
Code scanning / CodeQL
Wrong number of arguments in a call
Co-authored-by: Alex Fikl <alexfikl@gmail.com>
@kiike Looks good to me now! Ready to go? |
Yes! Let's do it! But if you want me to clean up the commit list so they are logically separated by what they want to do, I can do it to ease reverting/tracking when was something introduced. Just tell me or squash merge, I don't mind 😄 |
I don't know, squashing should be fine. My "rule" is just that when there's some "fix this and that" commits from the review => squash it 😁 Thank you for working on this! In it went 🚀 |
When I was developing an earlier PR, I wanted to test it on a vanilla installation of Windows, just to make sure no config could pollute the results.
Turns out, some tests fail on this kind of setup. Even with a benign but creepy Windows error popup during
![image](https://private-user-images.githubusercontent.com/464625/322044406-37ef9c2c-bcc2-4fd4-958a-42e6f542a707.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE3MTE3MDcsIm5iZiI6MTcyMTcxMTQwNywicGF0aCI6Ii80NjQ2MjUvMzIyMDQ0NDA2LTM3ZWY5YzJjLWJjYzItNGZkNC05NThhLTQyZTZmNTQyYTcwNy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzIzJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDcyM1QwNTEwMDdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zZjA0NjQwYzRkMGNjMzAzMWEzZDJlMWVlYThiNDY2YWYwY2IzODA1NzE0ZmM4ZDBmOWZlZDhiODY3MDc5Yzg1JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.Fe1c562YLpVx7Xlob3B3tSh_7NIPl4pteFTsTbDl2Zc)
tests/commands/open
.Some reasons for the failing tests:
mv
,echo
ormv
not present in vanilla Windows.Some details of this PR:
["git"] if git else []) + ["mv", folder, new_folder_path]
go, being so clever. I hope usingshutils
is OK.script.py
now hasls
too.Looking forward to your feedback! I think this PR getting in will make it a bit more polished when a new user tries the 0.14 release on Windows, wants to contribute, and tests pass on a fresh install!