mirror of
https://github.com/kiviktnm/decman.git
synced 2026-09-19 12:08:28 +00:00
Fix issues with tests and PKGBUILD reviewing
This commit is contained in:
@@ -606,7 +606,7 @@ class PackageBuilder:
|
|||||||
cmd = self._commands.make_chroot_pkg(
|
cmd = self._commands.make_chroot_pkg(
|
||||||
self.chroot_wd_dir, self.makepkg_user, chroot_pkg_files
|
self.chroot_wd_dir, self.makepkg_user, chroot_pkg_files
|
||||||
)
|
)
|
||||||
command.check_run_result(cmd, command.run(cmd))
|
command.check_run_result(cmd, command.pty_run(cmd))
|
||||||
|
|
||||||
for pkgname in package_names:
|
for pkgname in package_names:
|
||||||
file = self._find_pkgfile(pkgname, pkgbuild_dir)
|
file = self._find_pkgfile(pkgname, pkgbuild_dir)
|
||||||
@@ -819,11 +819,12 @@ class PackageBuilder:
|
|||||||
if output.prompt_confirm("Build this package?", default=True):
|
if output.prompt_confirm("Build this package?", default=True):
|
||||||
cmd = self._commands.git_get_commit_id()
|
cmd = self._commands.git_get_commit_id()
|
||||||
rc, git_output = command.run(cmd)
|
rc, git_output = command.run(cmd)
|
||||||
if rc != 0:
|
if rc == 0:
|
||||||
raise ForeignPackageManagerError(
|
|
||||||
f"Failed to get commit id for {pkgbase}."
|
|
||||||
) from errors.CommandFailedError(cmd, git_output)
|
|
||||||
commit_id = git_output.strip()
|
commit_id = git_output.strip()
|
||||||
self._store["pkgbuild_latest_reviewed_commits"][pkgbase] = commit_id
|
self._store["pkgbuild_latest_reviewed_commits"][pkgbase] = commit_id
|
||||||
|
else:
|
||||||
|
output.print_debug(
|
||||||
|
f"{pkgbase} is not in a git repository. Commit ID cannot be saved."
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
raise ForeignPackageManagerError("Building aborted.")
|
raise ForeignPackageManagerError("Building aborted.")
|
||||||
|
|||||||
@@ -280,8 +280,8 @@ class CustomPackage:
|
|||||||
try:
|
try:
|
||||||
with tempfile.TemporaryDirectory(prefix="decman-pkgbuild-") as tmpdir:
|
with tempfile.TemporaryDirectory(prefix="decman-pkgbuild-") as tmpdir:
|
||||||
tmp_path = pathlib.Path(tmpdir)
|
tmp_path = pathlib.Path(tmpdir)
|
||||||
# Allow the user 'nobody' to read here
|
# Allow the user 'nobody' to use this directory
|
||||||
os.chmod(tmpdir, 0o755)
|
os.chmod(tmpdir, 0o777)
|
||||||
shutil.copy(path / "PKGBUILD", tmp_path / "PKGBUILD")
|
shutil.copy(path / "PKGBUILD", tmp_path / "PKGBUILD")
|
||||||
os.chmod(tmp_path / "PKGBUILD", 0o644)
|
os.chmod(tmp_path / "PKGBUILD", 0o644)
|
||||||
|
|
||||||
@@ -298,7 +298,7 @@ class CustomPackage:
|
|||||||
try:
|
try:
|
||||||
with tempfile.TemporaryDirectory(prefix="decman-pkgbuild-") as tmpdir:
|
with tempfile.TemporaryDirectory(prefix="decman-pkgbuild-") as tmpdir:
|
||||||
tmp_path = pathlib.Path(tmpdir)
|
tmp_path = pathlib.Path(tmpdir)
|
||||||
# Allow the user 'nobody' to write here
|
# Allow the user 'nobody' to use this directory
|
||||||
os.chmod(tmpdir, 0o777)
|
os.chmod(tmpdir, 0o777)
|
||||||
try:
|
try:
|
||||||
cmd = commands.git_clone(self.git_url, tmpdir)
|
cmd = commands.git_clone(self.git_url, tmpdir)
|
||||||
|
|||||||
@@ -18,37 +18,13 @@ def test_run_exec_failure():
|
|||||||
assert "not" in out.lower()
|
assert "not" in out.lower()
|
||||||
|
|
||||||
|
|
||||||
def test_run_env_overrides_and_mimic_login_visible_in_child(monkeypatch):
|
def test_run_env_overrides_visible_in_child(monkeypatch):
|
||||||
class FakePw:
|
|
||||||
pw_dir = "/fake/home"
|
|
||||||
pw_name = "fakeuser"
|
|
||||||
pw_uid = 1000
|
|
||||||
pw_gid = 1000
|
|
||||||
pw_shell = "/bin/fakesh"
|
|
||||||
|
|
||||||
# Mock passwd lookup
|
|
||||||
monkeypatch.setattr(
|
|
||||||
"decman.core.command.pwd.getpwnam",
|
|
||||||
lambda user: FakePw(),
|
|
||||||
)
|
|
||||||
|
|
||||||
code, out = command.run(
|
code, out = command.run(
|
||||||
[
|
[
|
||||||
sys.executable,
|
sys.executable,
|
||||||
"-c",
|
"-c",
|
||||||
(
|
("import os, json; print(json.dumps({'FOO': os.environ['FOO'], }))"),
|
||||||
"import os, json; "
|
|
||||||
"print(json.dumps({"
|
|
||||||
"'FOO': os.environ['FOO'], "
|
|
||||||
"'HOME': os.environ['HOME'], "
|
|
||||||
"'USER': os.environ['USER'], "
|
|
||||||
"'LOGNAME': os.environ['LOGNAME'], "
|
|
||||||
"'SHELL': os.environ['SHELL']"
|
|
||||||
"}))"
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
user="fakeuser",
|
|
||||||
mimic_login=True,
|
|
||||||
env_overrides={"FOO": "BAR"},
|
env_overrides={"FOO": "BAR"},
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -56,10 +32,6 @@ def test_run_env_overrides_and_mimic_login_visible_in_child(monkeypatch):
|
|||||||
|
|
||||||
data = json.loads(out.strip())
|
data = json.loads(out.strip())
|
||||||
assert data["FOO"] == "BAR"
|
assert data["FOO"] == "BAR"
|
||||||
assert data["HOME"] == "/fake/home"
|
|
||||||
assert data["USER"] == "fakeuser"
|
|
||||||
assert data["LOGNAME"] == "fakeuser"
|
|
||||||
assert data["SHELL"] == "/bin/fakesh"
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(not sys.stdin.isatty(), reason="requires TTY")
|
@pytest.mark.skipif(not sys.stdin.isatty(), reason="requires TTY")
|
||||||
|
|||||||
Reference in New Issue
Block a user