| 364 | [("hardlink", system.is_hardlink), ("symlink", system.is_symlink)], |
| 365 | ) |
| 366 | def test_checkout_relink(tmp_dir, dvc, link, link_test_func): |
| 367 | dvc.cache.local.cache_types = [link] |
| 368 | |
| 369 | tmp_dir.dvc_gen({"dir": {"data": "text"}}) |
| 370 | |
| 371 | data_file = os.path.join("dir", "data") |
| 372 | |
| 373 | # NOTE: Windows symlink perms don't propagate to the target |
| 374 | if not (os.name == "nt" and link == "symlink"): |
| 375 | assert not os.access(data_file, os.W_OK) |
| 376 | |
| 377 | dvc.unprotect(data_file) |
| 378 | assert os.access(data_file, os.W_OK) |
| 379 | assert not link_test_func(data_file) |
| 380 | |
| 381 | assert dvc.checkout(["dir.dvc"], relink=True) == empty_checkout |
| 382 | assert link_test_func(data_file) |
| 383 | |
| 384 | # NOTE: Windows symlink perms don't propagate to the target and |
| 385 | # hardlink was chmod-ed during relink to be deleted |
| 386 | if not (os.name == "nt" and link in ["symlink", "hardlink"]): |
| 387 | assert not os.access(data_file, os.W_OK) |
| 388 | |
| 389 | |
| 390 | @pytest.mark.parametrize( |