From 3baa5e032b01eba6152b305938861b6fe373d15f Mon Sep 17 00:00:00 2001 From: Kivi Kaitaniemi Date: Thu, 18 Dec 2025 04:00:36 +0200 Subject: [PATCH] Fix issues with tests and PKGBUILD reviewing --- src/decman/plugins/aur/fpm.py | 15 ++++++++------- src/decman/plugins/aur/package.py | 6 +++--- tests/test_decman_core_command.py | 32 ++----------------------------- 3 files changed, 13 insertions(+), 40 deletions(-) diff --git a/src/decman/plugins/aur/fpm.py b/src/decman/plugins/aur/fpm.py index 9f74e81..167bbaa 100644 --- a/src/decman/plugins/aur/fpm.py +++ b/src/decman/plugins/aur/fpm.py @@ -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.") diff --git a/src/decman/plugins/aur/package.py b/src/decman/plugins/aur/package.py index af5b511..79417e7 100644 --- a/src/decman/plugins/aur/package.py +++ b/src/decman/plugins/aur/package.py @@ -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) diff --git a/tests/test_decman_core_command.py b/tests/test_decman_core_command.py index 2ac45fe..635dd28 100644 --- a/tests/test_decman_core_command.py +++ b/tests/test_decman_core_command.py @@ -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")