| 157 | @pytest.mark.skipif(os.name == "nt", reason="Not supported for Windows.") |
| 158 | @pytest.mark.parametrize("group", [False, True]) |
| 159 | def test_shared_cache(tmp_dir, dvc, group): |
| 160 | from dvc_data.hashfile.db.local import umask |
| 161 | |
| 162 | if group: |
| 163 | with dvc.config.edit() as conf: |
| 164 | conf["cache"].update({"shared": "group"}) |
| 165 | dvc.cache = CacheManager(dvc) |
| 166 | cache_dir = dvc.cache.local.path |
| 167 | |
| 168 | assert not os.path.exists(cache_dir) |
| 169 | |
| 170 | tmp_dir.dvc_gen({"file": "file content", "dir": {"file2": "file 2 content"}}) |
| 171 | |
| 172 | file_mode = oct(0o444) |
| 173 | dir_mode = oct(0o2775 if group else (0o777 & ~umask)) |
| 174 | for root, dnames, fnames in os.walk(cache_dir): |
| 175 | for dname in dnames: |
| 176 | path = os.path.join(root, dname) |
| 177 | assert oct(stat.S_IMODE(os.stat(path).st_mode)) == dir_mode |
| 178 | |
| 179 | for fname in fnames: |
| 180 | path = os.path.join(root, fname) |
| 181 | assert oct(stat.S_IMODE(os.stat(path).st_mode)) == file_mode |