diff --git a/network-poc/tests/Dockerfile.pytest b/network-poc/tests/Dockerfile.pytest new file mode 100644 index 0000000..c60a05f --- /dev/null +++ b/network-poc/tests/Dockerfile.pytest @@ -0,0 +1,5 @@ +FROM python:3.14-slim +COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv +WORKDIR /work +ENV PYTHONPATH=/work +ENTRYPOINT ["sh", "-c", "uv init --no-readme --python '>=3.14' 2>/dev/null && rm -f hello.py main.py && uv add fastapi 'uvicorn[standard]' sqlalchemy pytest httpx 2>/dev/null && cp /src/*.py . && rm -f app.db test.db && uv run pytest test_main.py -v --tb=short 2>&1"] diff --git a/network-poc/tests/model-benchmark.mjs b/network-poc/tests/model-benchmark.mjs index 7595828..18f0c58 100644 --- a/network-poc/tests/model-benchmark.mjs +++ b/network-poc/tests/model-benchmark.mjs @@ -335,20 +335,18 @@ async function runPipeline(model, scenario) { result.validationIssues = issues.length; result.fixRounds = fixRound; - // 5. Projektin alustus (uv init) + kirjoita tiedostot + pytest - console.log(` [5/5] Pytest...`); - try { - const uvPath = process.env.HOME + '/.local/bin/uv'; - const uv = existsSync(uvPath) ? uvPath : 'uv'; - execSync(`cd "${dir}" && ${uv} init --no-readme --python ">=3.14" 2>/dev/null && rm -f hello.py main.py`, { timeout: 30000, stdio: 'pipe' }); - execSync(`cd "${dir}" && ${uv} add fastapi "uvicorn[standard]" sqlalchemy pytest httpx 2>/dev/null`, { timeout: 60000, stdio: 'pipe' }); + // Kirjoita LLM:n generoimat Python-tiedostot + for (const [fn, content] of Object.entries(files)) { + if (fn.endsWith('.py')) writeFileSync(`${dir}/${fn}`, content); + } - // Kirjoita LLM:n generoimat Python-tiedostot (uv initin jälkeen) - for (const [fn, content] of Object.entries(files)) { - if (fn.endsWith('.py')) writeFileSync(`${dir}/${fn}`, content); - } - execSync(`cd "${dir}" && rm -f app.db test.db`, { stdio: 'pipe' }); - const pytestOut = execSync(`cd "${dir}" && ${uv} run pytest test_main.py -v --tb=short 2>&1`, { timeout: 60000, encoding: 'utf-8' }); + // 5. Pytest Docker-kontissa (kipina-pytest image) + console.log(` [5/5] Pytest (Docker)...`); + try { + const pytestOut = execSync( + `docker run --rm -v "${dir}:/src:ro" kipina-pytest 2>&1`, + { timeout: 120000, encoding: 'utf-8' } + ); writeFileSync(`${dir}/_pytest.txt`, pytestOut); const passedMatch = pytestOut.match(/(\d+) passed/);