Files

47 lines
2.0 KiB
PowerShell
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 專案全量測試:Python + Node 引擎 + 後端 REST + 前端語法
# 用法:.\scripts\run_all_tests.ps1
$ErrorActionPreference = 'Continue'
$root = Split-Path -Parent $PSScriptRoot
$py = Join-Path $root '.venv\Scripts\python.exe'
$node = 'C:\Users\ckliu\.cache\codex-runtimes\codex-primary-runtime\dependencies\node\bin\node.exe'
Set-Location $root
Write-Host "`n===== [1/4] Python 語法檢查 ====="
& $py -m py_compile game.py player.py game_record.py llm_client.py multi_game_runner.py game_analyze.py player_matchup_analyze.py json_convert.py project_env.py
if ($LASTEXITCODE -eq 0) { Write-Host " 語法 OK" } else { Write-Host " 語法失敗" }
Write-Host "`n===== [2/4] Python 引擎冒煙(mock LLM,不連網)====="
& $py scripts\smoke_test_python.py
Write-Host "`n===== [3/4] Node 引擎單元測試 ====="
& $node scripts\test_engine.js
Write-Host "`n===== [3.5/4] Node 後端 REST 冒煙 ====="
& $node scripts\smoke_test_server.js
Write-Host "`n===== [3.75/4] Node Socket e2e + reconnect ====="
& $node scripts\run_e2e_local.js
Write-Host "`n===== [4/4] 前端 SFC 語法 ====="
Push-Location client
& $node -e "
const { parse, compileScript, compileTemplate } = require('@vue/compiler-sfc');
const fs = require('fs');
let failed = 0;
for (const f of ['src/components/GameTable.vue','src/components/Lobby.vue','src/App.vue']) {
const src = fs.readFileSync(f, 'utf8');
const { descriptor, errors } = parse(src, { filename: f });
let errs = errors.map(e=>e.message||e);
if (!errs.length) { try { compileScript(descriptor, { id: 'x1' }); } catch (e) { errs.push('script: '+e.message); } }
if (descriptor.template) { const t = compileTemplate({ source: descriptor.template.content, filename: f, id: 'x2' }); if (t.errors.length) errs.push('template: '+t.errors.map(x=>x.message||x).join('|')); }
if (errs.length) { console.log('FAIL', f, errs.join('\n ')); failed++; } else { console.log('OK ', f); }
}
process.exit(failed?1:0);
"
$code = $LASTEXITCODE
Pop-Location
Write-Host "`n===== 完成(exit=$code====="
exit $code