Skip to content

Commit

Permalink
Debug pypy win32 links
Browse files Browse the repository at this point in the history
  • Loading branch information
Erotemic committed Jun 7, 2024
1 parent 7ff176b commit de70439
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions ubelt/_win32_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def _win32_can_symlink(verbose=0, force=0, testing=0):
Example:
>>> # xdoctest: +REQUIRES(WIN32)
>>> import ubelt as ub
>>> _win32_can_symlink(verbose=1, force=1, testing=1)
>>> _win32_can_symlink(verbose=3, force=1, testing=1)
"""
global __win32_can_symlink__
if verbose:
Expand Down Expand Up @@ -91,19 +91,19 @@ def _win32_can_symlink(verbose=0, force=0, testing=0):
util_io.touch(broken_fpath)

try:
_win32_symlink(dpath, dlink)
_win32_symlink(dpath, dlink, verbose=verbose)
if testing:
_win32_symlink(broken_dpath, join(tempdir, 'broken_dlink'))
_win32_symlink(broken_dpath, join(tempdir, 'broken_dlink'), verbose=verbose)
can_symlink_directories = os.path.islink(dlink)
except OSError:
can_symlink_directories = False
if verbose:
print('can_symlink_directories = {!r}'.format(can_symlink_directories))

try:
_win32_symlink(fpath, flink)
_win32_symlink(fpath, flink, verbose=verbose)
if testing:
_win32_symlink(broken_fpath, join(tempdir, 'broken_flink'))
_win32_symlink(broken_fpath, join(tempdir, 'broken_flink'), verbose=verbose)
can_symlink_files = os.path.islink(flink)
# os.path.islink(flink)
except OSError:
Expand All @@ -121,21 +121,25 @@ def _win32_can_symlink(verbose=0, force=0, testing=0):
if verbose:
print('Testing that we can create junctions, '
'even if symlinks are disabled')
djunc = _win32_junction(dpath, join(tempdir, 'djunc'))
fjunc = _win32_junction(fpath, join(tempdir, 'fjunc.txt'))
from ubelt import util_links
util_links._dirstats(tempdir)
print('^^ before ^^')

djunc = _win32_junction(dpath, join(tempdir, 'djunc'), verbose=verbose)
fjunc = _win32_junction(fpath, join(tempdir, 'fjunc.txt'), verbose=verbose)
if testing:
_win32_junction(broken_dpath, join(tempdir, 'broken_djunc'))
_win32_junction(broken_fpath, join(tempdir, 'broken_fjunc.txt'))
_win32_junction(broken_dpath, join(tempdir, 'broken_djunc'), verbose=verbose)
_win32_junction(broken_fpath, join(tempdir, 'broken_fjunc.txt'), verbose=verbose)
if not _win32_is_junction(djunc):
print('Error: djunc={djunc} claims to not be a junction')
print(f'Error: djunc={djunc} claims to not be a junction')
from ubelt import util_links
util_links._dirstats(tempdir)
raise AssertionError('expected djunc={djunc} to be a junction')
raise AssertionError(f'expected djunc={djunc} to be a junction')
if not _win32_is_hardlinked(fpath, fjunc):
print('Error: fjunc={fjunc} claims to not be a hardlink')
print(f'Error: fjunc={fjunc} claims to not be a hardlink')
from ubelt import util_links
util_links._dirstats(tempdir)
raise AssertionError('expected fjunc={fjunc} to be a hardlink')
raise AssertionError(f'expected fjunc={fjunc} to be a hardlink')
except Exception:
warnings.warn('We cannot create junctions either!')
raise
Expand Down

0 comments on commit de70439

Please sign in to comment.