Skip to content

Commit fbc0642

Browse files
committed
Add a test for (sym)link chains
1 parent fa69b69 commit fbc0642

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Lib/test/test_tarfile.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3755,6 +3755,32 @@ def test_deep_symlink(self):
37553755
else:
37563756
self.expect_file('linkdir/symlink', size=3)
37573757

3758+
@symlink_test
3759+
def test_chains(self):
3760+
# Test chaining of symlinks/hardlinks.
3761+
# Symlinks are created before the files they point to.
3762+
with ArchiveMaker() as arc:
3763+
arc.add('linkdir/symlink', symlink_to='hardlink')
3764+
arc.add('symlink2', symlink_to=os.path.join(
3765+
'linkdir', 'hardlink2'))
3766+
arc.add('targetdir/target', size=3)
3767+
arc.add('linkdir/hardlink', hardlink_to='targetdir/target')
3768+
arc.add('linkdir/hardlink2', hardlink_to='linkdir/symlink')
3769+
3770+
for filter in 'tar', 'data', 'fully_trusted':
3771+
with self.check_context(arc.open(), filter):
3772+
self.expect_file('targetdir/target', size=3)
3773+
self.expect_file('linkdir/hardlink', size=3)
3774+
self.expect_file('linkdir/hardlink2', size=3)
3775+
if os_helper.can_symlink():
3776+
self.expect_file('linkdir/symlink', size=3,
3777+
symlink_to='hardlink')
3778+
self.expect_file('symlink2', size=3,
3779+
symlink_to='linkdir/hardlink2')
3780+
else:
3781+
self.expect_file('linkdir/symlink', size=3)
3782+
self.expect_file('symlink2', size=3)
3783+
37583784
def test_modes(self):
37593785
# Test how file modes are extracted
37603786
# (Note that the modes are ignored on platforms without working chmod)

0 commit comments

Comments
 (0)