test: change permissions of testfiles only $SPHINX_READONLY_TESTDIR set

This commit is contained in:
Takeshi KOMIYA
2021-02-05 00:39:29 +09:00
parent 32257ee524
commit 1fc7bc6b1e
+10 -9
View File
@@ -109,15 +109,16 @@ class path(str):
pointed to by the symbolic links are copied.
"""
shutil.copytree(self, destination, symlinks=symlinks)
# If source tree is marked read-only (e.g. because it is on a read-only
# filesystem), `shutil.copytree` will mark the destination as read-only
# as well. To avoid failures when adding additional files/directories
# to the destination tree, ensure destination directories are not marked
# read-only.
for root, dirs, files in os.walk(destination):
os.chmod(root, 0o755 & ~UMASK)
for name in files:
os.chmod(os.path.join(root, name), 0o644 & ~UMASK)
if os.environ.get('SPHINX_READONLY_TESTDIR'):
# If source tree is marked read-only (e.g. because it is on a read-only
# filesystem), `shutil.copytree` will mark the destination as read-only
# as well. To avoid failures when adding additional files/directories
# to the destination tree, ensure destination directories are not marked
# read-only.
for root, dirs, files in os.walk(destination):
os.chmod(root, 0o755 & ~UMASK)
for name in files:
os.chmod(os.path.join(root, name), 0o644 & ~UMASK)
def movetree(self, destination: str) -> None:
"""