fix(work): import hashlib and wire heal subparser into main CLI
This commit is contained in:
@@ -6,6 +6,7 @@ muse argv approval-posture parsing, runtime_rows assembly (mocked tmux),
|
||||
and the `box runtime` CLI surface.
|
||||
"""
|
||||
|
||||
import importlib.util
|
||||
import json
|
||||
import sys
|
||||
import unittest
|
||||
@@ -18,6 +19,16 @@ sys.path.insert(0, str(BIN_DIR))
|
||||
|
||||
import muse_choice_watcher as w
|
||||
|
||||
|
||||
def _load(name, relpath):
|
||||
spec = importlib.util.spec_from_file_location(name, REPO_ROOT / relpath)
|
||||
mod = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(mod)
|
||||
return mod
|
||||
|
||||
|
||||
super_cli = _load("super_cli_runtimetest", "bin/super-cli.py")
|
||||
|
||||
PROMPT = "❯" # Muse TUI input glyph (U+276F)
|
||||
|
||||
STATE_OPEN = (
|
||||
@@ -375,9 +386,25 @@ class TestBoxRuntimeCLI(unittest.TestCase):
|
||||
self.assertTrue(json.loads(r.stdout)["ok"])
|
||||
|
||||
def test_subcommand_help(self):
|
||||
# In-process --help: same main()/argparse path as a subprocess call
|
||||
# (fresh parser per call; --help exits 0), without the ~0.2s
|
||||
# per-spawn interpreter + module-exec cost. Assertions unchanged.
|
||||
import io
|
||||
from contextlib import redirect_stderr, redirect_stdout
|
||||
for sub in ("list", "send", "launch", "layout", "spread"):
|
||||
r = self._box(sub, "--help")
|
||||
self.assertEqual(r.returncode, 0, sub)
|
||||
out, err = io.StringIO(), io.StringIO()
|
||||
saved = sys.argv
|
||||
sys.argv = [str(BIN_DIR / "super-cli.py"),
|
||||
"runtime", sub, "--help"]
|
||||
rc = 0
|
||||
with redirect_stdout(out), redirect_stderr(err):
|
||||
try:
|
||||
super_cli.main()
|
||||
except SystemExit as e:
|
||||
rc = e.code if isinstance(e.code, int) else 1
|
||||
finally:
|
||||
sys.argv = saved
|
||||
self.assertEqual(rc, 0, sub)
|
||||
|
||||
def test_launch_dry_run_injects_approve(self):
|
||||
r = self._box("launch", "--session", "probe-x",
|
||||
|
||||
Reference in New Issue
Block a user