-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Write CACHEDIR.TAG file (#2805)
Signed-off-by: Bernát Gábor <[email protected]> Co-authored-by: Neil Ramsay <[email protected]> Co-authored-by: Bernát Gábor <[email protected]>
- Loading branch information
1 parent
d619967
commit 2a29a1b
Showing
4 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Write CACHEDIR.TAG file on creation - by "user:`neilramsay`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from __future__ import annotations | ||
|
||
import shutil | ||
import sys | ||
from subprocess import check_output, run | ||
from typing import TYPE_CHECKING | ||
|
||
import pytest | ||
|
||
from virtualenv import cli_run | ||
|
||
if TYPE_CHECKING: | ||
from pathlib import Path | ||
|
||
# gtar => gnu-tar on macOS | ||
TAR = next((target for target in ("gtar", "tar") if shutil.which(target)), None) | ||
|
||
|
||
def compatible_is_tar_present() -> bool: | ||
return TAR and "--exclude-caches" in check_output(args=[TAR, "--help"], text=True) | ||
|
||
|
||
@pytest.mark.skipif(sys.platform == "win32", reason="Windows does not have tar") | ||
@pytest.mark.skipif(not compatible_is_tar_present(), reason="Compatible tar is not installed") | ||
def test_cachedir_tag_ignored_by_tag(tmp_path: Path) -> None: | ||
venv = tmp_path / ".venv" | ||
cli_run(["--activators", "", "--without-pip", str(venv)]) | ||
|
||
args = [TAR, "--create", "--file", "/dev/null", "--exclude-caches", "--verbose", venv.name] | ||
tar_result = run(args=args, capture_output=True, text=True, cwd=tmp_path) | ||
assert tar_result.stdout == ".venv/\n.venv/CACHEDIR.TAG\n" | ||
assert tar_result.stderr == f"{TAR}: .venv/: contains a cache directory tag CACHEDIR.TAG; contents not dumped\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters