Skip to content

Investigate TestCmdCacheDir failing on MacOs and non-realpath repo. #4752

@pared

Description

@pared

In #4673, on MacOs we need to expand the temporary directory to its real path in order to make a test for relative cache dir setup pass. I tried to investigate why it fails without os.path.realpath and came up with following test:

def test_cmd_cache_dir_relative_path(make_tmp_dir):
    d = make_tmp_dir("temp")
    pv = d / "private" / "var"
    os.makedirs(pv)

    l = d / "var"
    System.symlink(pv, l)

    cache_path = l / "cache"

    repo_path = l / "repo"
    os.makedirs(repo_path)
    with repo_path.chdir():
        repo = Repo.init(no_scm=True)

        dname = relpath(cache_path)
        assert main(["cache", "dir", dname]) == 0

        rel = os.path.join("..", dname)
        config = configobj.ConfigObj(repo.config.files["repo"])
        assert config["cache"]["dir"] == rel.replace("\\", "/")

        repo_path.gen("foo", "foo content")
        assert main(["add", "foo"]) == 0

The test seems to pass both on Linux and MacOs.

Investigate why TestCmdCacheDir fails if we don't wrap self.mkdtemp in os.path.realpath in case of MacOs.

MacOs version of failing runner:
Mac OS X - 10.15.7
DVC version: 1.8.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions