From e0b0457b8bb4d99d3c29777404e9f8fdaab88470 Mon Sep 17 00:00:00 2001 From: WuYongJie Date: Fri, 28 Aug 2026 22:09:40 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E4=BF=AE=E5=A4=8D=20Windows=20Prisma?= =?UTF-8?q?=20=E6=B5=8B=E8=AF=95=E5=90=AF=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/run-tests.mjs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/run-tests.mjs b/scripts/run-tests.mjs index dcb4e1e..abaa187 100644 --- a/scripts/run-tests.mjs +++ b/scripts/run-tests.mjs @@ -8,11 +8,12 @@ const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..') const testPrefix = 'yyd-notification-center-test-' const testRoot = mkdtempSync(join(tmpdir(), testPrefix)) const databasePath = join(testRoot, 'notifications.db') -const databaseUrl = `file:${databasePath}` +// Prisma 的 SQLite file URL 必须使用正斜杠;Windows 原生反斜杠会让 schema-engine 无细节退出。 +const databaseUrl = `file:${databasePath.split(sep).join('/')}` const childEnv = { ...process.env, DATABASE_URL: databaseUrl } // Prisma 5.22 的 Windows schema-engine 在部分主机未初始化 Rust 日志时会无细节提前退出。 // 只在 Windows 测试子进程中启用;Linux/Docker 不受影响,也不会记录数据库内容或密钥。 -if (process.platform === 'win32' && !childEnv.RUST_LOG) childEnv.RUST_LOG = 'trace' +if (process.platform === 'win32') childEnv.RUST_LOG = 'trace' const runNode = (args) => { const result = spawnSync(process.execPath, args, { @@ -38,7 +39,8 @@ const removeTestRoot = () => { let exitCode = 0 try { const prismaCli = resolve(repoRoot, 'node_modules', 'prisma', 'build', 'index.js') - const schema = resolve(repoRoot, 'prisma', 'schema.prisma') + // cwd 已固定为 repoRoot;避免 Windows schema-engine 处理含空格的绝对 schema 路径失败。 + const schema = 'prisma/schema.prisma' exitCode = runNode([prismaCli, 'migrate', 'deploy', '--schema', schema]) if (exitCode === 0) { const tsxCli = resolve(repoRoot, 'node_modules', 'tsx', 'dist', 'cli.mjs')