From bc9ca140bd6891d2be510bd1db7927e3b8b8bb1d Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 10 Dec 2025 10:37:40 +0100 Subject: [PATCH] fix(e2e): treat SystemExit(0) as successful CLI termination in clone-all test The pkgmgr proxy layer may intentionally terminate the process via SystemExit(0). The previous test logic interpreted any SystemExit as a failure, causing false negatives during `pkgmgr clone --all` E2E runs. This patch updates `test_clone_all.py` to: - accept SystemExit(0) as a successful run, - only fail on non-zero exit codes, - preserve diagnostic output for real failures. This stabilizes the clone-all E2E test across proxy-triggered exits. https://chatgpt.com/share/69393f6b-b854-800f-aabb-25811bbb8c74 --- tests/e2e/test_clone_all.py | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/tests/e2e/test_clone_all.py b/tests/e2e/test_clone_all.py index 0c2ee93..9553c87 100644 --- a/tests/e2e/test_clone_all.py +++ b/tests/e2e/test_clone_all.py @@ -26,6 +26,11 @@ class TestIntegrationCloneAllHttps(unittest.TestCase): """ Helper that runs the CLI command via main.py and provides extra diagnostics if the command exits with a non-zero code. + + Note: + The pkgmgr CLI may exit via SystemExit(0) on success + (e.g. when handled by the proxy layer). In that case we + treat the test as successful and do not raise. """ cmd_repr = "pkgmgr clone --all --clone-mode https --no-verification" original_argv = sys.argv @@ -44,19 +49,36 @@ class TestIntegrationCloneAllHttps(unittest.TestCase): # This will run the full clone 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) + # Determine the exit code (int or string) + exit_code = exc.code + if isinstance(exit_code, int): + numeric_code = exit_code + else: + try: + numeric_code = int(exit_code) + except (TypeError, ValueError): + numeric_code = None + # Treat SystemExit(0) as success (expected behavior) + if numeric_code == 0: + print( + "\n[TEST] pkgmgr clone --all finished with SystemExit(0); " + "treating as success." + ) + return + + # For non-zero exit codes: convert SystemExit into a more + # helpful assertion with debug output. print("\n[TEST] pkgmgr clone --all failed with SystemExit") print(f"[TEST] Command : {cmd_repr}") - print(f"[TEST] Exit code: {exit_code}") + print(f"[TEST] Exit code: {exit_code!r}") # Additional Nix profile debug on failure (may still be useful # if the clone step interacts with Nix-based tooling). nix_profile_list_debug("ON FAILURE (AFTER SystemExit)") raise AssertionError( - f"{cmd_repr!r} failed with exit code {exit_code}. " + f"{cmd_repr!r} failed with exit code {exit_code!r}. " "Scroll up to see the full pkgmgr/make output inside the container." ) from exc