Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion backend/routes/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import subprocess
import tempfile
import os
import sys
from fastapi import APIRouter, HTTPException
from models.schemas import PluginRun, PluginResult
from services import db_service
Expand Down Expand Up @@ -152,7 +153,7 @@ def _coderunner(code: str) -> str:

try:
result = subprocess.run(
["python3", tmp],
[sys.executable, tmp],
capture_output=True, text=True, timeout=5
)
output = result.stdout or result.stderr or "(no output)"
Expand Down
16 changes: 16 additions & 0 deletions backend/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,22 @@ def test_unknown_plugin():
assert r.status_code == 400


def test_coderunner_success():
r = client.post("/api/plugins/run", json={"plugin": "coderunner", "input": "print('hello world')"})
assert r.status_code == 200
assert r.json()["success"]
assert "hello world" in r.json()["output"]


def test_coderunner_timeout():
r = client.post("/api/plugins/run", json={
"plugin": "coderunner",
"input": "import time\ntime.sleep(6)"
})
assert r.status_code == 200
assert r.json()["success"]
assert "Timeout" in r.json()["output"]

# ─── Settings ────────────────────────────────────────────
def test_get_settings():
r = client.get("/api/settings/")
Expand Down
Loading