no-mistakes(review): Manage lint tools and preserve Pi packages

This commit is contained in:
Lap Tran committed 2026-11-23 17:31:01 -05:00
1 parent 4a31495181
commit 022967e277
4 files changed
+70 -48

No files matched your search

+57
View File
@@ -268,11 +268,68 @@ class RebuildUpdates(unittest.TestCase):
self.assertEqual(self.state["skills"]["security-audit"], "old")
self.assertIn(["pi", "update", "--extensions", "--no-approve"], self.calls)
def test_pi_packages_are_not_retired(self):
packages = ("pi-cli", "pi-coding-agent", "pi-context")
for name in packages:
(self.root / "global_modules" / name).mkdir(parents=True)
self.state["packages"][name] = "1.0.0"
for private_copy in (False, True):
with self.subTest(private_copy=private_copy):
if private_copy:
(self.home / ".pi/agent/npm/node_modules/pi-context").mkdir(parents=True)
self.execute()
self.assertFalse(any(call[:2] == ["npm", "uninstall"] and
call[-1] in packages for call in self.calls))
for name in packages:
self.assertEqual(self.state["packages"][name], "1.0.0")
self.assertTrue((self.root / "global_modules" / name).is_dir())
self.assertIn(["pi", "update", "--extensions", "--no-approve"], self.calls)
def test_managed_lint_tool_backups_rotate(self):
for name in ("actionlint", "shellcheck"):
path = self.home / ".local/bin" / (name + ".backup")
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text("previous binary")
self.execute()
for name in ("actionlint", "shellcheck"):
path = self.home / ".local/bin" / (name + ".backup")
self.assertFalse(path.exists())
rotated = list(path.parent.glob(name + ".backup.*"))
self.assertEqual(len(rotated), 1)
self.assertEqual(rotated[0].read_text(), "previous binary")
def test_switch_failure_stops_post_switch_updates(self):
self.state["switch_status"] = 1
self.execute()
self.assertFalse(any(call[0] in ("npx", "pi") for call in self.calls))
class ManagedLintTools(unittest.TestCase):
def test_commands_follow_selected_nixpkgs_packages(self):
nix = shutil.which("nix")
self.assertIsNotNone(nix, "Missing required test tool: nix")
expression = '''
let
system = (builtins.getFlake (toString ./.)).darwinConfigurations."lt-mbp";
files = system.config.home-manager.users.laptran.home.file;
in builtins.map (name: {
inherit name;
source = toString files.${".local/bin/" + name}.source;
force = files.${".local/bin/" + name}.force;
package = toString system.pkgs.${name};
}) [ "actionlint" "shellcheck" ]
'''
result = subprocess.run(
[nix, "eval", "--json", "--impure", "--expr", expression],
cwd=ROOT, text=True, capture_output=True, timeout=120,
)
self.assertEqual(result.returncode, 0, result.stderr)
for command in json.loads(result.stdout):
with self.subTest(name=command["name"]):
self.assertEqual(command["source"],
command["package"] + "/bin/" + command["name"])
self.assertTrue(command["force"])
if __name__ == "__main__":
unittest.main()