Run every claude the loop starts in a Claude home generated outside the clone
CI / tests (pull_request) Successful in 4m45s
CI / tests (pull_request) Successful in 4m45s
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
import json
|
||||
import pathlib
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from repo_checks import ROOT
|
||||
|
||||
|
||||
class Install(unittest.TestCase):
|
||||
def test_the_readme_adds_each_settings_marketplace_and_installs_every_enabled_plugin(self):
|
||||
settings = json.loads((ROOT / "settings.json").read_text(encoding="utf-8"))
|
||||
readme = (ROOT / "README.md").read_text(encoding="utf-8")
|
||||
for plugin, enabled in settings["enabledPlugins"].items():
|
||||
if enabled:
|
||||
self.assertIn(f"claude plugin install {plugin}\n", readme)
|
||||
# settings.json declares the marketplace, or `claude plugin marketplace add` writes it there.
|
||||
marketplace = settings["extraKnownMarketplaces"][plugin.split("@")[1]]["source"]["repo"]
|
||||
self.assertIn(f"claude plugin marketplace add {marketplace}\n", readme)
|
||||
@@ -0,0 +1,31 @@
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from repo_checks import ROOT
|
||||
|
||||
# Runs a launcher as a Python of the version in argv[2] would, up to its first import of the setup's own code.
|
||||
AS_VERSION = "import sys; launcher = sys.argv[1]; sys.version_info = tuple(map(int, sys.argv[2].split('.'))); sys.version = sys.argv[2] + ' (main)'; sys.argv = [launcher, '--help']; exec(compile(open(launcher).read(), launcher, 'exec'), {'__file__': launcher, '__name__': '__main__'})"
|
||||
|
||||
|
||||
class LauncherPython(unittest.TestCase):
|
||||
def ran(self, tool: str, version: str) -> subprocess.CompletedProcess[str]:
|
||||
return subprocess.run([sys.executable, "-c", AS_VERSION, str(ROOT / "bin" / tool), version], capture_output=True, text=True)
|
||||
|
||||
def test_a_command_that_starts_claudes_names_the_python_it_needs_where_python3_is_older(self) -> None:
|
||||
for tool in ("build-epic", "build-release"):
|
||||
with self.subTest(tool):
|
||||
ran = self.ran(tool, "3.13.9")
|
||||
|
||||
self.assertEqual((ran.returncode, ran.stdout, ran.stderr), (1, "", f"{tool} needs Python 3.14 or later as python3 on PATH; it found Python 3.13.9\n"))
|
||||
|
||||
def test_it_starts_on_the_python_it_needs(self) -> None:
|
||||
for tool in ("build-epic", "build-release"):
|
||||
with self.subTest(tool):
|
||||
ran = self.ran(tool, "3.14.0")
|
||||
|
||||
self.assertEqual((ran.returncode, ran.stderr), (0, ""))
|
||||
self.assertIn(f"usage: {tool}", ran.stdout)
|
||||
@@ -11,7 +11,8 @@ RESOLVED_ELSEWHERE = re.compile(
|
||||
r"""["']\.claude["'/]"""
|
||||
r"""|["']\.config["'/]"""
|
||||
r"""|["']\.local["'/]"""
|
||||
r"""|["']XDG_(CONFIG|STATE)_HOME["']"""
|
||||
r"""|["']XDG_(CONFIG|DATA|STATE)_HOME["']"""
|
||||
r"""|["']CLAUDE_CONFIG_DIR["']"""
|
||||
r"""|__file__\)\.resolve\(\)\.parents\["""
|
||||
)
|
||||
|
||||
|
||||
@@ -5,22 +5,35 @@ import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from settings_filter import cleaned
|
||||
from git_cli.git_repo import git
|
||||
from claude_home.home import CLONE
|
||||
from repo_checks import ROOT
|
||||
|
||||
INSTALL = "git config filter.settings.clean bin/settings_filter.py"
|
||||
|
||||
|
||||
class Settings(unittest.TestCase):
|
||||
def test_the_stored_settings_hold_no_model_and_sorted_keys(self):
|
||||
# The index, not the working file: the working file holds this machine's model in Claude Code's key order.
|
||||
stored = git("show", ":settings.json", cwd=str(ROOT))
|
||||
self.assertIsInstance(stored, str, stored)
|
||||
fix = f"commit settings.json with the filter on: {INSTALL}"
|
||||
self.assertNotIn("model", json.loads(stored), fix)
|
||||
self.assertEqual(stored, cleaned(json.loads(stored)), fix)
|
||||
def setUp(self) -> None:
|
||||
self.text = (ROOT / "settings.json").read_text(encoding="utf-8")
|
||||
self.settings = json.loads(self.text)
|
||||
|
||||
def test_the_readme_installs_the_filter_git_attributes_names_for_the_root_settings_only(self):
|
||||
self.assertEqual("/settings.json filter=settings\n", (ROOT / ".gitattributes").read_text(encoding="utf-8"))
|
||||
self.assertIn(f"{INSTALL}\n", (ROOT / "README.md").read_text(encoding="utf-8"))
|
||||
def test_the_tracked_settings_hold_no_model_and_sorted_keys(self) -> None:
|
||||
# A model belongs to the generated settings.json in the loop's Claude home, where /model writes it.
|
||||
self.assertNotIn("model", self.settings)
|
||||
self.assertEqual(self.text, json.dumps(self.settings, indent=2, sort_keys=True) + "\n")
|
||||
|
||||
def test_every_hook_runs_a_tool_of_the_clone(self) -> None:
|
||||
commands = [hook["command"] for groups in self.settings["hooks"].values() for group in groups for hook in group["hooks"]]
|
||||
|
||||
self.assertTrue(commands)
|
||||
for command in commands:
|
||||
self.assertTrue(command.startswith(f"{CLONE}/bin/"), command)
|
||||
self.assertTrue((ROOT / "bin" / command.split()[0].removeprefix(f"{CLONE}/bin/")).is_file(), command)
|
||||
|
||||
def test_the_persons_theme_and_status_line_are_not_set(self) -> None:
|
||||
self.assertNotIn("theme", self.settings)
|
||||
self.assertNotIn("statusLine", self.settings)
|
||||
|
||||
def test_every_enabled_plugins_marketplace_names_the_repo_the_home_adds_it_from(self) -> None:
|
||||
enabled = [plugin for plugin, enabled in self.settings["enabledPlugins"].items() if enabled]
|
||||
|
||||
self.assertTrue(enabled)
|
||||
for plugin in enabled:
|
||||
self.assertRegex(self.settings["extraKnownMarketplaces"][plugin.split("@")[1]]["source"]["repo"], r"^[\w.-]+/[\w.-]+$", plugin)
|
||||
|
||||
Reference in New Issue
Block a user