Skip to content

Commit 84dbe44

Browse files
committed
pkg_tar: Add a test that checks that symlinks won't shadow directories
1 parent b74ae68 commit 84dbe44

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/tar/tar_writer_test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,19 @@ def testDirectoryDoesNotShadowSymlink(self):
313313
]
314314
self.assertTarFileContent(self.tempfile, content)
315315

316+
def testSymlinkDoesNotShadowDirectory(self):
317+
with tar_writer.TarFileWriter(self.tempfile, create_parents=True, allow_dups_from_deps=False) as f:
318+
f.add_file("target_dir", tarfile.DIRTYPE)
319+
f.add_file("not_a_symlink", tarfile.DIRTYPE)
320+
f.add_file("not_a_symlink", tarfile.SYMTYPE, link="target_dir")
321+
f.add_file('not_a_symlink/a', content="q")
322+
content = [
323+
{"name": "target_dir", "type": tarfile.DIRTYPE},
324+
{"name": "not_a_symlink", "type": tarfile.DIRTYPE},
325+
{"name": "not_a_symlink/a", "type": tarfile.REGTYPE},
326+
]
327+
self.assertTarFileContent(self.tempfile, content)
328+
316329

317330
if __name__ == "__main__":
318331
unittest.main()

0 commit comments

Comments
 (0)