test_archive_6.py 739 B

123456789101112131415161718192021
  1. def test_extract_preserve_executables_from_zip(self):
  2. zip = qibuild.command.find_program("zip")
  3. if not zip:
  4. return
  5. src = os.path.join(self.tmp, "src")
  6. os.mkdir(src)
  7. a_exe = os.path.join(src, "a.exe")
  8. with open(a_exe, "w") as fp:
  9. fp.write("a_exe\n")
  10. st_700 = stat.S_IXUSR | stat.S_IRUSR | stat.S_IWUSR
  11. os.chmod(a_exe, st_700)
  12. qibuild.command.call(["zip", "-r", "src.zip", "src"],
  13. cwd=self.tmp)
  14. archive = os.path.join(self.tmp, "src.zip")
  15. dest = os.path.join(self.tmp, "dest")
  16. os.mkdir(dest)
  17. qibuild.archive.extract_zip(archive, dest)
  18. dest_exe = os.path.join(dest, "src", "a.exe")
  19. st_mode = os.stat(dest_exe).st_mode
  20. self.assertEquals(st_mode, 100700)