Skip to content
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

testsuite: only use follow_symlinks if supported #7754

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/borg/testsuite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ def is_utime_fully_supported():
else:
open(filepath, "w").close()
try:
os.utime(filepath, (1000, 2000), follow_symlinks=False)
new_stats = os.stat(filepath, follow_symlinks=False)
os.utime(filepath, (1000, 2000), follow_symlinks=False if os.utime in os.supports_follow_symlinks else True)
new_stats = os.stat(filepath, follow_symlinks=False if os.stat in os.supports_follow_symlinks else True)
Comment on lines 149 to +151
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, guess that needs to be done differently:
The code right above either creates a symlink (with a non-existing target as it seems) or a file.
So we can't just arbitrarily switch follow_symlinks to True/False below:

  • the target does not exist
  • also, line 144 seems to imply we want to know about utime behaviour on symlinks

So guess this needs double-checking:

  • what tests do use this and what exactly do we need to check here?
  • the utime call needs to match the fs object it is used with

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also: never use a condition to decide between True or False. Above, you could've just used follow_symlinks=os.stat not in os.supports_follow_symlinks.

Reads a bit strange, but guess that's because the default (and always supported) behaviour is with True and the special (and sometimes unsupported) behaviour is with False.

if new_stats.st_atime == 1000 and new_stats.st_mtime == 2000:
return True
except OSError:
Expand Down