Improve installer debugging and enhance E2E test diagnostics
- Added rich error reporting to install_repos() for clearer installer failure context (repository identifier, repo directory, installer name, exit code). - Updated E2E test 'install_all_shallow' to show additional diagnostics, including Nix profile dumps and contextual SystemExit handling. - Removed outdated/deactivated test file. - New test now mirrors the robust debugging flow of the pkgmgr-only test. See conversation for full context: https://chatgpt.com/share/6936241b-52ec-800f-9859-1734a581c002
This commit is contained in:
@@ -238,5 +238,40 @@ def install_repos(
|
|||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
# Debug + aussagekräftiger Fehler bei Installer-Fail
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
if not quiet:
|
||||||
|
print(
|
||||||
|
f"[pkgmgr] Running installer {installer.__class__.__name__} "
|
||||||
|
f"for {identifier} in '{repo_dir}' "
|
||||||
|
f"(new capabilities: {caps or '∅'})..."
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
installer.run(ctx)
|
installer.run(ctx)
|
||||||
|
except SystemExit as exc:
|
||||||
|
exit_code = exc.code if isinstance(exc.code, int) else str(exc.code)
|
||||||
|
|
||||||
|
print(
|
||||||
|
f"[ERROR] Installer {installer.__class__.__name__} failed "
|
||||||
|
f"for repository {identifier} (dir: {repo_dir}) "
|
||||||
|
f"with exit code {exit_code}."
|
||||||
|
)
|
||||||
|
print(
|
||||||
|
"[ERROR] This usually means an underlying command failed "
|
||||||
|
"(e.g. 'make install', 'nix build', 'pip install', ...)."
|
||||||
|
)
|
||||||
|
print(
|
||||||
|
"[ERROR] Check the log above for the exact command output. "
|
||||||
|
"You can also run this repository in isolation via:\n"
|
||||||
|
f" pkgmgr install {identifier} --clone-mode shallow --no-verification"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Re-raise, damit CLI/Test sauber fehlschlägt,
|
||||||
|
# aber nun mit deutlich mehr Kontext.
|
||||||
|
raise
|
||||||
|
|
||||||
|
# Nur wenn der Installer erfolgreich war, Capabilities mergen
|
||||||
provided_capabilities.update(caps)
|
provided_capabilities.update(caps)
|
||||||
|
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
"""
|
|
||||||
Integration test: install all configured repositories using
|
|
||||||
--clone-mode shallow (HTTPS shallow clone) and --no-verification.
|
|
||||||
|
|
||||||
This test is intended to be run inside the Docker container where:
|
|
||||||
- network access is available,
|
|
||||||
- the config/config.yaml is present,
|
|
||||||
- and it is safe to perform real git operations.
|
|
||||||
|
|
||||||
It passes if the command completes without raising an exception.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import runpy
|
|
||||||
import sys
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
|
|
||||||
class TestIntegrationInstallAllShallow(unittest.TestCase):
|
|
||||||
def test_install_all_repositories_shallow(self):
|
|
||||||
"""
|
|
||||||
Run: pkgmgr install --all --clone-mode shallow --no-verification
|
|
||||||
|
|
||||||
This will perform real installations/clones inside the container.
|
|
||||||
The test succeeds if no exception is raised.
|
|
||||||
"""
|
|
||||||
original_argv = sys.argv
|
|
||||||
try:
|
|
||||||
sys.argv = [
|
|
||||||
"pkgmgr",
|
|
||||||
"install",
|
|
||||||
"--all",
|
|
||||||
"--clone-mode",
|
|
||||||
"shallow",
|
|
||||||
"--no-verification",
|
|
||||||
]
|
|
||||||
|
|
||||||
# Execute main.py as if it was called from CLI.
|
|
||||||
# This will run the full install pipeline inside the container.
|
|
||||||
runpy.run_module("main", run_name="__main__")
|
|
||||||
|
|
||||||
finally:
|
|
||||||
sys.argv = original_argv
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
unittest.main()
|
|
||||||
91
tests/e2e/test_integration_install_all_shallow.py
Normal file
91
tests/e2e/test_integration_install_all_shallow.py
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
"""
|
||||||
|
Integration test: install all configured repositories using
|
||||||
|
--clone-mode shallow (HTTPS shallow clone) and --no-verification.
|
||||||
|
|
||||||
|
This test is intended to be run inside the Docker container where:
|
||||||
|
- network access is available,
|
||||||
|
- the config/config.yaml is present,
|
||||||
|
- and it is safe to perform real git operations.
|
||||||
|
|
||||||
|
It passes if the command completes without raising an exception.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import runpy
|
||||||
|
import sys
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from test_integration_install_pkgmgr_shallow import (
|
||||||
|
nix_profile_list_debug,
|
||||||
|
remove_pkgmgr_from_nix_profile,
|
||||||
|
pkgmgr_help_debug,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TestIntegrationInstallAllShallow(unittest.TestCase):
|
||||||
|
def _run_pkgmgr_install_all(self) -> None:
|
||||||
|
"""
|
||||||
|
Helper that runs the CLI command via main.py and provides
|
||||||
|
extra diagnostics if the command exits with a non-zero code.
|
||||||
|
"""
|
||||||
|
cmd_repr = "pkgmgr install --all --clone-mode shallow --no-verification"
|
||||||
|
original_argv = sys.argv
|
||||||
|
try:
|
||||||
|
sys.argv = [
|
||||||
|
"pkgmgr",
|
||||||
|
"install",
|
||||||
|
"--all",
|
||||||
|
"--clone-mode",
|
||||||
|
"shallow",
|
||||||
|
"--no-verification",
|
||||||
|
]
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Execute main.py as if it was called from CLI.
|
||||||
|
# This will run the full install pipeline inside the container.
|
||||||
|
runpy.run_module("main", run_name="__main__")
|
||||||
|
except SystemExit as exc:
|
||||||
|
# Convert SystemExit into a more helpful assertion with debug output.
|
||||||
|
exit_code = exc.code if isinstance(exc.code, int) else str(exc.code)
|
||||||
|
|
||||||
|
print("\n[TEST] pkgmgr install --all failed with SystemExit")
|
||||||
|
print(f"[TEST] Command : {cmd_repr}")
|
||||||
|
print(f"[TEST] Exit code: {exit_code}")
|
||||||
|
|
||||||
|
# Additional Nix profile debug on failure
|
||||||
|
nix_profile_list_debug("ON FAILURE (AFTER SystemExit)")
|
||||||
|
|
||||||
|
raise AssertionError(
|
||||||
|
f"{cmd_repr!r} failed with exit code {exit_code}. "
|
||||||
|
"Scroll up to see the full pkgmgr/make output inside the container."
|
||||||
|
) from exc
|
||||||
|
|
||||||
|
finally:
|
||||||
|
sys.argv = original_argv
|
||||||
|
|
||||||
|
def test_install_all_repositories_shallow(self) -> None:
|
||||||
|
"""
|
||||||
|
Run: pkgmgr install --all --clone-mode shallow --no-verification
|
||||||
|
|
||||||
|
This will perform real installations/clones inside the container.
|
||||||
|
The test succeeds if no exception is raised and `pkgmgr --help`
|
||||||
|
works in a fresh interactive bash session afterwards.
|
||||||
|
"""
|
||||||
|
# Debug before cleanup
|
||||||
|
nix_profile_list_debug("BEFORE CLEANUP")
|
||||||
|
|
||||||
|
# Cleanup: aggressively try to drop any pkgmgr/profile entries
|
||||||
|
remove_pkgmgr_from_nix_profile()
|
||||||
|
|
||||||
|
# Debug after cleanup
|
||||||
|
nix_profile_list_debug("AFTER CLEANUP")
|
||||||
|
|
||||||
|
# Run the actual install with extended diagnostics
|
||||||
|
self._run_pkgmgr_install_all()
|
||||||
|
|
||||||
|
# After successful installation: show `pkgmgr --help`
|
||||||
|
# via interactive bash (same as the pkgmgr-only test).
|
||||||
|
pkgmgr_help_debug()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
Reference in New Issue
Block a user