test: cover explicit git -C terminal probe
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""Tests for native MCP preference gate and shell circuit breaker (#270)."""
|
||||
import sys
|
||||
import unittest
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
@@ -76,11 +77,33 @@ class TestTerminalDiagnostics(unittest.TestCase):
|
||||
self.assertEqual(res["error_type"], "missing cwd")
|
||||
|
||||
def test_probe_terminal_spawn_honors_custom_command(self):
|
||||
res = nmp.probe_terminal_spawn(command=[sys.executable, "-c", "raise SystemExit(3)"])
|
||||
res = nmp.probe_terminal_spawn(
|
||||
command=[sys.executable, "-c", "raise SystemExit(3)"]
|
||||
)
|
||||
self.assertTrue(res["healthy"])
|
||||
self.assertEqual(res["command"][0], sys.executable)
|
||||
self.assertEqual(res["exit_code"], 3)
|
||||
|
||||
@unittest.skipUnless(shutil.which("git"), "git is required for git -C probe")
|
||||
def test_probe_terminal_spawn_supports_explicit_git_c_worktree(self):
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
subprocess.run(
|
||||
["git", "init", tmp],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
res = nmp.probe_terminal_spawn(
|
||||
cwd="/",
|
||||
command=["git", "-C", tmp, "status", "--short"],
|
||||
)
|
||||
|
||||
self.assertTrue(res["healthy"])
|
||||
self.assertEqual(res["command"][1], "-C")
|
||||
|
||||
def test_probe_terminal_spawn_blocks_missing_custom_command(self):
|
||||
res = nmp.probe_terminal_spawn(command=["nonexistent_exec_for_test"])
|
||||
self.assertFalse(res["healthy"])
|
||||
|
||||
Reference in New Issue
Block a user