From 3a47b7d60b0bdd0dd3896df0aed7d93d21efde74 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Feb 2026 04:28:31 +0000 Subject: [PATCH 2/4] Add Docker image cleanup to test fixture Co-authored-by: bandrel <3598052+bandrel@users.noreply.github.com> --- tests/test_docker_script_install.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/test_docker_script_install.py b/tests/test_docker_script_install.py index 6b3516c..6d5040d 100644 --- a/tests/test_docker_script_install.py +++ b/tests/test_docker_script_install.py @@ -1,6 +1,7 @@ import os import shutil import subprocess +import uuid from pathlib import Path import pytest @@ -17,7 +18,8 @@ def _require_docker(): def docker_image(): _require_docker() repo_root = Path(__file__).resolve().parents[1] - image_tag = "hate-crack-e2e" + # Use a unique tag per test run to avoid conflicts + image_tag = f"hate-crack-e2e-{uuid.uuid4().hex[:8]}" try: build = subprocess.run( @@ -33,7 +35,20 @@ def docker_image(): "Docker build failed. " f"stdout={build.stdout} stderr={build.stderr}" ) - return image_tag + + yield image_tag + + # Cleanup: remove the Docker image after tests complete + try: + subprocess.run( + ["docker", "image", "rm", image_tag], + capture_output=True, + text=True, + timeout=60, + ) + except Exception: + # Don't fail the test if cleanup fails + pass def _run_container(image_tag, command, timeout=180): From c00d257430f34ef628379b6ccedb886a1d5e0522 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Feb 2026 04:29:09 +0000 Subject: [PATCH 3/4] Improve error logging in Docker image cleanup Co-authored-by: bandrel <3598052+bandrel@users.noreply.github.com> --- tests/test_docker_script_install.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_docker_script_install.py b/tests/test_docker_script_install.py index 6d5040d..0d8132b 100644 --- a/tests/test_docker_script_install.py +++ b/tests/test_docker_script_install.py @@ -1,6 +1,7 @@ import os import shutil import subprocess +import sys import uuid from pathlib import Path @@ -46,9 +47,9 @@ def docker_image(): text=True, timeout=60, ) - except Exception: - # Don't fail the test if cleanup fails - pass + except Exception as e: + # Don't fail the test if cleanup fails, but log the issue + print(f"Warning: Failed to remove Docker image {image_tag}: {e}", file=sys.stderr) def _run_container(image_tag, command, timeout=180): From 229caa09c9a2e162ea934389327d71c63a99af42 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Feb 2026 04:29:41 +0000 Subject: [PATCH 4/4] Check return code and log stderr on cleanup failure Co-authored-by: bandrel <3598052+bandrel@users.noreply.github.com> --- tests/test_docker_script_install.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/test_docker_script_install.py b/tests/test_docker_script_install.py index 0d8132b..69d73a2 100644 --- a/tests/test_docker_script_install.py +++ b/tests/test_docker_script_install.py @@ -41,15 +41,21 @@ def docker_image(): # Cleanup: remove the Docker image after tests complete try: - subprocess.run( + result = subprocess.run( ["docker", "image", "rm", image_tag], capture_output=True, text=True, timeout=60, ) + if result.returncode != 0: + print( + f"Warning: Failed to remove Docker image {image_tag}. " + f"stderr={result.stderr}", + file=sys.stderr + ) except Exception as e: # Don't fail the test if cleanup fails, but log the issue - print(f"Warning: Failed to remove Docker image {image_tag}: {e}", file=sys.stderr) + print(f"Warning: Exception while removing Docker image {image_tag}: {e}", file=sys.stderr) def _run_container(image_tag, command, timeout=180):