Files
6krrt/tests/test_opencode_plugins.py

35 lines
983 B
Python

"""Test wrapper for opencode plugin node tests.
Runs ``node --test deploy/opencode-plugin/`` and fails if any node test
fails. Skips only when ``node`` is not on PATH (with that reason).
"""
import shutil
import subprocess
import pytest
@pytest.fixture(scope="session")
def node_on_path():
"""Return True when ``node`` is available on PATH."""
return shutil.which("node") is not None
def test_opencode_plugins(node_on_path):
"""Run node's built-in test runner on the opencode plugin directory."""
if not node_on_path:
pytest.skip("node not found on PATH")
result = subprocess.run(
["node", "--test", "deploy/opencode-plugin/"],
capture_output=True,
text=True,
check=False,
)
# node --test exits 0 on all-pass, non-zero on any failure.
assert result.returncode == 0, (
f"node --test deploy/opencode-plugin/ failed (exit {result.returncode}):\n"
f"{result.stdout}\n{result.stderr}"
)