From 72812447fddef828dcff39d16afa036e19856c52 Mon Sep 17 00:00:00 2001 From: Wxw-Gu <84499436+Wxw-Gu@users.noreply.github.com> Date: Wed, 14 Oct 2026 11:35:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20Windows=20CI=20?= =?UTF-8?q?=E4=B8=A4=E4=B8=AA=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit after-pack-signing:断言改用 POSIX 归一化,消除同一文件里 join() 与硬编码斜杠混用 voice-recognition:用例改用内存库与纯字符串路径,去掉落盘 SQLite 与临时目录删除 --- tests/unit/after-pack-signing.test.ts | 15 ++++++++--- tests/unit/voice-recognition-use-case.test.ts | 26 ++++++++++--------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/tests/unit/after-pack-signing.test.ts b/tests/unit/after-pack-signing.test.ts index 99f50fa..017f136 100644 --- a/tests/unit/after-pack-signing.test.ts +++ b/tests/unit/after-pack-signing.test.ts @@ -1,7 +1,7 @@ import { createRequire } from 'module' import { mkdirSync, mkdtempSync, rmSync, symlinkSync, writeFileSync } from 'fs' import { tmpdir } from 'os' -import { join } from 'path' +import { join, sep } from 'path' import { afterAll, describe, expect, it } from 'vitest' const nodeRequire = createRequire(import.meta.url) @@ -94,7 +94,16 @@ function fixtureApp(): string { } const app = fixtureApp() -const relative = (target: string): string => target.slice(app.length + 1) +/** + * 归一化成 POSIX 风格再断言。 + * + * `findNestedMacosCodePaths()` 返回的是**平台原生路径**(Windows runner 上是反斜杠), + * 而这一组用例验证的是**签名顺序算法** —— 谁必须排在谁前面 —— 跟分隔符毫无关系。 + * 归一化之后,层次可以直接用 `Contents/Frameworks/...` 这样的字面量表达, + * 既读得懂,也不会再出现"同一文件里一半 `join()`、一半硬编码斜杠"的混用。 + */ +const relative = (target: string): string => + target.slice(app.length + 1).split(sep).join('/') describe('macOS nested code signing order', () => { afterAll(() => rmSync(root, { recursive: true, force: true })) @@ -102,7 +111,7 @@ describe('macOS nested code signing order', () => { it('signs nested code inside-out and ignores resources and symlinks', () => { const paths = findNestedMacosCodePaths(app).map(relative) - expect(paths).toContain(join('Contents', 'MacOS', 'TraceMemo')) + expect(paths).toContain('Contents/MacOS/TraceMemo') expect(paths).not.toContain(app) expect(paths.some((entry) => entry.includes('Resources'))).toBe(false) expect(paths.some((entry) => entry.endsWith('.md'))).toBe(false) diff --git a/tests/unit/voice-recognition-use-case.test.ts b/tests/unit/voice-recognition-use-case.test.ts index d127dde..19a1d6f 100644 --- a/tests/unit/voice-recognition-use-case.test.ts +++ b/tests/unit/voice-recognition-use-case.test.ts @@ -1,17 +1,23 @@ -import { mkdtempSync, rmSync } from 'fs' -import { tmpdir } from 'os' import { join } from 'path' -import { afterEach, describe, expect, it, vi } from 'vitest' +import { describe, expect, it, vi } from 'vitest' import { VoiceRecognitionUseCase } from '../../src/main/voice-pipeline/voice-recognition-use-case' -const roots: string[] = [] - +/** + * 这组用例验证的是**转写更新的编排**:命中缓存/新识别是否走同一条 update path、 + * 账号代号中途变化时是否取消发布、force 是否透传给 pipeline。真正的 + * `pipeline.run` 与 `modelManager.getStatus` 都被 mock,所以**不需要真实的 + * 文件系统或 SQLite**。 + * + * 用内存库 + 纯字符串路径(不建目录、不落盘、不删除): + * `SqliteTranscriptRepository` 一旦落盘就会连带生成 `-wal` / `-shm`, + * 每个用例还要 `rmSync` 整棵临时树 —— 这些在 Windows runner 上(Defender 实时扫描 + * 每次文件创建/删除)会放大到秒级,而对被测行为零贡献。 + */ function createUseCase(): VoiceRecognitionUseCase { - const root = mkdtempSync(join(tmpdir(), 'wxe-voice-use-case-')) - roots.push(root) + const root = join('wxe-voice-use-case-fixture', 'account-a') const useCase = new VoiceRecognitionUseCase({ modelRoot: join(root, 'model'), - databasePath: join(root, 'transcripts.sqlite'), + databasePath: ':memory:', workerPath: join(root, 'unused-worker.js') }) const state = useCase as unknown as { @@ -36,10 +42,6 @@ function createUseCase(): VoiceRecognitionUseCase { return useCase } -afterEach(async () => { - for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true }) -}) - describe('VoiceRecognitionUseCase transcript updates', () => { it('publishes a successful cache hit through the same update path as fresh recognition', async () => { const useCase = createUseCase()