Add complete uninstall reset for fresh native installations

This commit is contained in:
2026-11-08 19:16:46 +00:00
parent e17bc2ca4f
commit 828227f549
6 changed files with 317 additions and 0 deletions
+44
View File
@@ -5,6 +5,7 @@ from pathlib import Path
import subprocess
import tempfile
import unittest
from unittest.mock import patch
spec = importlib.util.spec_from_file_location("pipelines_uninstall", Path(__file__).with_name("uninstall.py"))
uninstall = importlib.util.module_from_spec(spec)
@@ -218,3 +219,46 @@ class UninstallTests(unittest.TestCase):
self.assertTrue(any(owned in c and "rm" in c for c in docker), owned)
for unrelated in ("deadbeef", "baadf00d"):
self.assertFalse(any(unrelated in c and "rm" in c for c in docker), unrelated)
def test_custom_cache_cannot_delete_checkout_source(self):
source = self.put(self.repo / "app/lib/main.dart", "keep source")
self.environment["PIPELINES_APP_CACHE"] = str(self.repo / "app")
with self.assertRaises(ValueError):
self.resetter().run()
self.assertEqual(source.read_text(), "keep source")
self.assertEqual(self.recorder.calls, [])
def test_only_owned_hosts_and_manual_supervisor_are_terminated(self):
original = self.recorder
commands = [f"{self.prefix}/bin/pipelines-claude-host --socket fixture",
f"python3 {self.prefix}/lib/manage.py supervise --prefix {self.prefix}",
f"node {self.prefix}/lib/web/serve.mjs --port 8082",
"codex app-server", f"{self.home}/other/bin/pipelines-claude-host"]
def processes(command, **kwargs):
if command[0] == "ps":
return subprocess.CompletedProcess(command, 0, stdout="\n".join(
f"{40001 + i} {text}" for i, text in enumerate(commands)), stderr="")
return original(command, **kwargs)
signalled = []
def signal_process(pid, number):
if number == 0:
raise ProcessLookupError()
signalled.append(pid)
with patch.object(uninstall.os, "kill", side_effect=signal_process):
uninstall.Uninstall(home=self.home, repo=self.repo, environ={},
runner=processes, system="Linux").run()
self.assertEqual(signalled, [40001, 40002, 40003])
def test_macos_reset_uses_only_its_launch_agent(self):
unit = self.put(self.home / "Library/LaunchAgents/net.a-wan.pipelines.plist",
"Managed by Pipelines native installer")
neighbor = self.put(unit.parent / "other.plist", "keep")
uninstall.Uninstall(home=self.home, repo=self.repo, environ={},
runner=self.recorder, system="Darwin").run()
self.assertFalse(unit.exists())
self.assertEqual(neighbor.read_text(), "keep")
self.assertTrue(any(c[:2] == ["launchctl", "bootout"] for c in self.recorder.calls))
self.assertFalse(any(c[0] == "systemctl" for c in self.recorder.calls))