feat(install): add --update to re-run active-layer installers and improve Nix refresh logic
Some checks failed
CI / test-unit (push) Has been cancelled
CI / test-integration (push) Has been cancelled
CI / test-env-virtual (push) Has been cancelled
CI / test-env-nix (push) Has been cancelled
CI / test-e2e (push) Has been cancelled
CI / test-virgin-user (push) Has been cancelled
CI / test-virgin-root (push) Has been cancelled
CI / codesniffer-shellcheck (push) Has been cancelled
CI / codesniffer-ruff (push) Has been cancelled
Some checks failed
CI / test-unit (push) Has been cancelled
CI / test-integration (push) Has been cancelled
CI / test-env-virtual (push) Has been cancelled
CI / test-env-nix (push) Has been cancelled
CI / test-e2e (push) Has been cancelled
CI / test-virgin-user (push) Has been cancelled
CI / test-virgin-root (push) Has been cancelled
CI / codesniffer-shellcheck (push) Has been cancelled
CI / codesniffer-ruff (push) Has been cancelled
* Add `force_update` to `RepoContext` and propagate it through install/update flows * Add `pkgmgr install --update` to force re-running installers even if the same CLI layer is already loaded * Enhance `NixFlakeInstaller` to ensure correct outputs (pkgmgr + optional default for package-manager) and support refresh/upgrade with index-based fallback remove+reinstall * Make Python/Makefile installers emit an “upgraded” marker when `force_update` is used * Add E2E tests for “three times install” scenarios (makefile, nix, venv) with shared run helper * Fix git safe.directory wildcard quoting in E2E shell runner and minor cleanup/reordering of imports/comments https://chatgpt.com/share/693db0b4-6ea4-800f-b44a-f03939c7fb9e
This commit is contained in:
24
tests/e2e/_util.py
Normal file
24
tests/e2e/_util.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import subprocess
|
||||
|
||||
|
||||
def run(cmd, *, cwd=None, env=None, shell=False) -> str:
|
||||
proc = subprocess.run(
|
||||
cmd,
|
||||
cwd=cwd,
|
||||
env=env,
|
||||
shell=shell,
|
||||
text=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
)
|
||||
|
||||
print("----- BEGIN COMMAND -----")
|
||||
print(cmd if isinstance(cmd, str) else " ".join(cmd))
|
||||
print("----- OUTPUT -----")
|
||||
print(proc.stdout.rstrip())
|
||||
print("----- END COMMAND -----")
|
||||
|
||||
if proc.returncode != 0:
|
||||
raise AssertionError(proc.stdout)
|
||||
|
||||
return proc.stdout
|
||||
25
tests/e2e/test_install_makefile_three_times.py
Normal file
25
tests/e2e/test_install_makefile_three_times.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from tests.e2e._util import run
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
class TestMakefileThreeTimes(unittest.TestCase):
|
||||
def test_make_install_three_times(self):
|
||||
with tempfile.TemporaryDirectory(prefix="makefile-3x-") as tmp:
|
||||
repo = Path(tmp)
|
||||
|
||||
# Minimal Makefile with install target
|
||||
(repo / "Makefile").write_text(
|
||||
"install:\n\t@echo install >> install.log\n"
|
||||
)
|
||||
|
||||
for i in range(1, 4):
|
||||
print(f"\n=== RUN {i}/3 ===")
|
||||
run(["make", "install"], cwd=repo)
|
||||
|
||||
log = (repo / "install.log").read_text().splitlines()
|
||||
self.assertEqual(
|
||||
len(log),
|
||||
3,
|
||||
"make install should have been executed exactly three times",
|
||||
)
|
||||
37
tests/e2e/test_install_pkgmgr_three_times_nix.py
Normal file
37
tests/e2e/test_install_pkgmgr_three_times_nix.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import os
|
||||
from tests.e2e._util import run
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class TestPkgmgrInstallThreeTimesNix(unittest.TestCase):
|
||||
def test_three_times_install_nix(self):
|
||||
with tempfile.TemporaryDirectory(prefix="pkgmgr-nix-") as tmp:
|
||||
tmp_path = Path(tmp)
|
||||
|
||||
env = os.environ.copy()
|
||||
env["HOME"] = tmp
|
||||
|
||||
# Ensure nix is found
|
||||
env["PATH"] = "/nix/var/nix/profiles/default/bin:" + os.environ.get("PATH", "")
|
||||
|
||||
# IMPORTANT:
|
||||
# nix run uses git+file:///src internally -> Git will reject /src if it's not a safe.directory.
|
||||
# Our test sets HOME to a temp dir, so we must provide a temp global gitconfig.
|
||||
gitconfig = tmp_path / ".gitconfig"
|
||||
gitconfig.write_text(
|
||||
"[safe]\n"
|
||||
"\tdirectory = /src\n"
|
||||
"\tdirectory = /src/.git\n"
|
||||
"\tdirectory = *\n"
|
||||
)
|
||||
env["GIT_CONFIG_GLOBAL"] = str(gitconfig)
|
||||
|
||||
for i in range(1, 4):
|
||||
print(f"\n=== RUN {i}/3 ===")
|
||||
run(
|
||||
"nix run .#pkgmgr -- install pkgmgr --update --clone-mode shallow --no-verification",
|
||||
env=env,
|
||||
shell=True,
|
||||
)
|
||||
34
tests/e2e/test_install_pkgmgr_three_times_venv.py
Normal file
34
tests/e2e/test_install_pkgmgr_three_times_venv.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from tests.e2e._util import run
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
import os
|
||||
|
||||
|
||||
class TestPkgmgrInstallThreeTimesVenv(unittest.TestCase):
|
||||
def test_three_times_install_venv(self):
|
||||
with tempfile.TemporaryDirectory(prefix="pkgmgr-venv-") as tmp:
|
||||
home = Path(tmp)
|
||||
bin_dir = home / ".local" / "bin"
|
||||
bin_dir.mkdir(parents=True)
|
||||
|
||||
env = os.environ.copy()
|
||||
env["HOME"] = tmp
|
||||
|
||||
# pkgmgr kommt aus dem Projekt-venv
|
||||
env["PATH"] = (
|
||||
f"{Path.cwd() / '.venv' / 'bin'}:"
|
||||
f"{bin_dir}:"
|
||||
+ os.environ.get("PATH", "")
|
||||
)
|
||||
|
||||
# nix explizit deaktivieren → Python/Venv-Pfad
|
||||
env["PKGMGR_DISABLE_NIX_FLAKE_INSTALLER"] = "1"
|
||||
|
||||
for i in range(1, 4):
|
||||
print(f"\n=== RUN {i}/3 ===")
|
||||
run(
|
||||
"pkgmgr install pkgmgr --update --clone-mode shallow --no-verification",
|
||||
env=env,
|
||||
shell=True,
|
||||
)
|
||||
Reference in New Issue
Block a user