experiments: preserve file permissions across tmpdir execution (#4890)

* tree: use file_mode in upload() for trees that support modes

* experiments: preserve file_mode for files in the workspace

* skip permissions tests on windows

* LocalTree: separate chmod from protect

* fix rebase issue
This commit is contained in:
Peter Rowlands (변기호)
2020-11-18 00:47:57 +09:00
committed by GitHub
parent 379ed8e6fc
commit 40bdf613f0
11 changed files with 107 additions and 31 deletions
@@ -1,4 +1,6 @@
import logging
import os
import stat
import pytest
from funcy import first
@@ -19,6 +21,18 @@ def test_new_simple(tmp_dir, scm, dvc, exp_stage, mocker):
).read_text() == "foo: 2"
@pytest.mark.skipif(os.name == "nt", reason="Not supported for Windows.")
def test_file_permissions(tmp_dir, scm, dvc, exp_stage, mocker):
mode = 0o755
os.chmod(tmp_dir / "copy.py", mode)
scm.add(["copy.py"])
scm.commit("set exec")
tmp_dir.gen("params.yaml", "foo: 2")
dvc.experiments.run(exp_stage.addressing)
assert stat.S_IMODE(os.stat(tmp_dir / "copy.py").st_mode) == mode
def test_failed_exp(tmp_dir, scm, dvc, exp_stage, mocker, caplog):
from dvc.stage.exceptions import StageCmdFailedError