vinix-ports / ports / git / check.py
27 lines · 24 sloc · 1.08 KB · c33d8afc2906b8dd9a8b905224eccd49a44f7ad5
Raw
1"""Exercise Git's target object, index, reference and PCRE code offline."""
2from pathlib import Path
3import os
4import subprocess
5
6source = Path.cwd()
7binary = source / "git-2.47.3/git"
8work = source / "git-check"
9work.mkdir()
10os.chdir(work)
11os.environ.update(GIT_CONFIG_NOSYSTEM="1", HOME=str(work), GIT_TERMINAL_PROMPT="0",
12 GIT_AUTHOR_NAME="Vinix", GIT_AUTHOR_EMAIL="test@invalid",
13 GIT_COMMITTER_NAME="Vinix", GIT_COMMITTER_EMAIL="test@invalid")
14
15def git(*args, data=None):
16 return subprocess.check_output(["vinix-run", str(binary), *args], input=data, text=True).strip()
17
18git("init", "-q", "--template=")
19(work / "file").write_text("Vinix\n")
20git("add", "file")
21tree = git("write-tree")
22commit = git("commit-tree", tree, data="First commit\n")
23git("update-ref", "HEAD", commit)
24if git("show", "HEAD:file") != "Vinix" or git("grep", "-P", "(?=Vini)Vinix") != "file:Vinix":
25 raise SystemExit("target Git object or PCRE result did not match")
26if not (source / "git-2.47.3/git-remote-http").is_file():
27 raise SystemExit("target Git HTTP transport is missing")
28