test_archive_10.py 892 B

1234567891011121314151617181920212223
  1. def test_extract_with_symlink_and_change_topdir(self):
  2. if sys.platform.startswith("win"):
  3. return
  4. src = os.path.join(self.tmp, "src")
  5. os.mkdir(src)
  6. a_long_dir = os.path.join(src, "a_long_dir")
  7. os.mkdir(a_long_dir)
  8. a_file = os.path.join(a_long_dir, "a_file")
  9. with open(a_file, "w") as fp:
  10. fp.write("a_file\n")
  11. a_link = os.path.join(a_long_dir, "a_link")
  12. os.symlink("a_file", a_link)
  13. tar_gz = qibuild.archive.zip_unix(a_long_dir)
  14. dest = os.path.join(self.tmp, "dest")
  15. os.mkdir(dest)
  16. qibuild.archive.extract(tar_gz, dest, topdir="a_dir")
  17. ls_r = qibuild.sh.ls_r(dest)
  18. self.assertEquals(ls_r,
  19. ['a_dir/a_file', 'a_dir/a_link'])
  20. dest_link = os.path.join(dest, "a_dir", "a_link")
  21. self.assertTrue(os.path.islink(dest_link))
  22. dest_target = os.readlink(dest_link)
  23. self.assertEquals(dest_target, "a_file")