61 lines
1.7 KiB
Python
61 lines
1.7 KiB
Python
from __future__ import annotations
|
|
|
|
import os
|
|
import subprocess
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
|
|
RUNTIME_SCRIPT = Path(__file__).with_name("pi-orca-runtime.fish")
|
|
SYSTEM_NODE = Path("/usr/bin/node")
|
|
WORK_NODE = Path(
|
|
"/home/jb/.local/share/fnm/node-versions/v22.23.2/installation/bin/node"
|
|
)
|
|
|
|
|
|
class ConfigurePiOrcaRuntimeTests(unittest.TestCase):
|
|
def configure_runtime(self, profile: str) -> list[str]:
|
|
environment = os.environ.copy()
|
|
environment["PATH"] = ":".join(
|
|
[str(WORK_NODE.parent), "/usr/local/bin", "/usr/bin"]
|
|
)
|
|
command = """
|
|
source $argv[1]
|
|
configure_pi_orca_runtime $argv[2]
|
|
printf '%s\\n' $pi_orca_node_executable $PI_CODING_AGENT_DIR $PATH[1] (command -v node)
|
|
"""
|
|
result = subprocess.run(
|
|
["/usr/bin/fish", "-c", command, str(RUNTIME_SCRIPT), profile],
|
|
check=True,
|
|
capture_output=True,
|
|
env=environment,
|
|
text=True,
|
|
)
|
|
return result.stdout.splitlines()
|
|
|
|
def test_default_profile_prioritizes_system_node(self) -> None:
|
|
self.assertEqual(
|
|
self.configure_runtime("pi-harness-tools"),
|
|
[
|
|
str(SYSTEM_NODE),
|
|
"/home/jb/.pi/agent",
|
|
str(SYSTEM_NODE.parent),
|
|
str(SYSTEM_NODE),
|
|
],
|
|
)
|
|
|
|
def test_work_profile_prioritizes_node_22(self) -> None:
|
|
self.assertEqual(
|
|
self.configure_runtime("pi-work"),
|
|
[
|
|
str(WORK_NODE),
|
|
"/home/jb/.pi/profiles/cyone",
|
|
str(WORK_NODE.parent),
|
|
str(WORK_NODE),
|
|
],
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|