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(
|
||||
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:
|
||||
file = self._find_pkgfile(pkgname, pkgbuild_dir)
|
||||
@@ -819,11 +819,12 @@ class PackageBuilder:
|
||||
if output.prompt_confirm("Build this package?", default=True):
|
||||
cmd = self._commands.git_get_commit_id()
|
||||
rc, git_output = command.run(cmd)
|
||||
if rc != 0:
|
||||
raise ForeignPackageManagerError(
|
||||
f"Failed to get commit id for {pkgbase}."
|
||||
) from errors.CommandFailedError(cmd, git_output)
|
||||
commit_id = git_output.strip()
|
||||
self._store["pkgbuild_latest_reviewed_commits"][pkgbase] = commit_id
|
||||
if rc == 0:
|
||||
commit_id = git_output.strip()
|
||||
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:
|
||||
raise ForeignPackageManagerError("Building aborted.")
|
||||
|
||||
@@ -280,8 +280,8 @@ class CustomPackage:
|
||||
try:
|
||||
with tempfile.TemporaryDirectory(prefix="decman-pkgbuild-") as tmpdir:
|
||||
tmp_path = pathlib.Path(tmpdir)
|
||||
# Allow the user 'nobody' to read here
|
||||
os.chmod(tmpdir, 0o755)
|
||||
# Allow the user 'nobody' to use this directory
|
||||
os.chmod(tmpdir, 0o777)
|
||||
shutil.copy(path / "PKGBUILD", tmp_path / "PKGBUILD")
|
||||
os.chmod(tmp_path / "PKGBUILD", 0o644)
|
||||
|
||||
@@ -298,7 +298,7 @@ class CustomPackage:
|
||||
try:
|
||||
with tempfile.TemporaryDirectory(prefix="decman-pkgbuild-") as 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)
|
||||
try:
|
||||
cmd = commands.git_clone(self.git_url, tmpdir)
|
||||
|
||||
@@ -18,37 +18,13 @@ def test_run_exec_failure():
|
||||
assert "not" in out.lower()
|
||||
|
||||
|
||||
def test_run_env_overrides_and_mimic_login_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(),
|
||||
)
|
||||
|
||||
def test_run_env_overrides_visible_in_child(monkeypatch):
|
||||
code, out = command.run(
|
||||
[
|
||||
sys.executable,
|
||||
"-c",
|
||||
(
|
||||
"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']"
|
||||
"}))"
|
||||
),
|
||||
("import os, json; print(json.dumps({'FOO': os.environ['FOO'], }))"),
|
||||
],
|
||||
user="fakeuser",
|
||||
mimic_login=True,
|
||||
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())
|
||||
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")
|
||||
|
||||
Reference in New Issue
Block a user