Skip to content

Commit 8ac15c4

Browse files
committed
test(windows): unblock primary-mode allowlist match and skip POSIX-only ci-smoke
Two unrelated test fixtures that both keep the windows-advisory advisory red: - `packages/app/src/no-mode-picker.test.ts`: the allowlist stores entries with POSIX-style paths but `path.relative` returns backslashes on Windows, so the allowlist never matched and the legitimate `context/global-sync/utils.ts` reference flagged as an offender. Normalize `relPath` to forward slashes before comparing, mirroring the same fix applied earlier to `agent-rename.test.ts`. - `packages/desktop-electron/scripts/ci-smoke.test.ts`: the "packaged smoke reports spawn failures with launch context" fixture relies on an empty file + chmod 0o755 to hit ENOEXEC and exercise the `Failed to launch desktop app:` branch. Windows has no equivalent (empty files via cmd exit cleanly through a different branch), and the assertion targets the spawn error format rather than Windows-specific launch semantics. Gate the test with `test.skipIf(process.platform === "win32")`. Refs #426
1 parent a264f50 commit 8ac15c4

2 files changed

Lines changed: 36 additions & 24 deletions

File tree

packages/app/src/no-mode-picker.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ test('no source file in packages/app/src uses mode === "primary" outside the all
4848
const lines = text.split(/\r?\n/)
4949
lines.forEach((lineText, i) => {
5050
if (!re.test(lineText)) return
51-
const relPath = path.relative(APP_SRC, file)
51+
// Normalize to forward slashes so the Windows backslash form of
52+
// `path.relative` still matches MODE_PRIMARY_ALLOWLIST entries authored
53+
// with POSIX-style paths.
54+
const relPath = path.relative(APP_SRC, file).replaceAll(path.sep, "/")
5255
const ok = MODE_PRIMARY_ALLOWLIST.some((a) => a.file === relPath && a.line === i + 1)
5356
if (!ok) offenders.push({ file: relPath, line: i + 1, text: lineText.trim() })
5457
})

packages/desktop-electron/scripts/ci-smoke.test.ts

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -114,27 +114,36 @@ describe("ci smoke helpers", () => {
114114
})
115115
})
116116

117-
test("packaged smoke reports spawn failures with launch context", () => {
118-
const dir = mkdtempSync(path.join(tmpdir(), "pawwork-ci-smoke-"))
119-
try {
120-
const executablePath = path.join(dir, "PawWork")
121-
writeFileSync(executablePath, "")
122-
chmodSync(executablePath, 0o755)
123-
124-
const result = spawnSync(
125-
process.execPath,
126-
[path.join(import.meta.dir, "ci-smoke.ts"), "packaged", "dev", executablePath],
127-
{
128-
encoding: "utf8",
129-
timeout: 5_000,
130-
},
131-
)
132-
133-
expect(result.status).not.toBe(0)
134-
expect(`${result.stdout}${result.stderr}`).toContain("Failed to launch desktop app:")
135-
expect(`${result.stdout}${result.stderr}`).toContain(executablePath)
136-
} finally {
137-
rmSync(dir, { recursive: true, force: true })
138-
}
139-
})
117+
// POSIX-only: the fixture relies on creating an empty file with chmod 0o755
118+
// to trigger an ENOEXEC spawn error so ci-smoke.ts emits the
119+
// "Failed to launch desktop app:" branch. Windows has no direct equivalent
120+
// (empty files run through cmd exit cleanly, sending the flow through the
121+
// "Electron exited" branch instead), and the assertion targets the spawn
122+
// error format itself, not Windows-specific launch behavior.
123+
test.skipIf(process.platform === "win32")(
124+
"packaged smoke reports spawn failures with launch context",
125+
() => {
126+
const dir = mkdtempSync(path.join(tmpdir(), "pawwork-ci-smoke-"))
127+
try {
128+
const executablePath = path.join(dir, "PawWork")
129+
writeFileSync(executablePath, "")
130+
chmodSync(executablePath, 0o755)
131+
132+
const result = spawnSync(
133+
process.execPath,
134+
[path.join(import.meta.dir, "ci-smoke.ts"), "packaged", "dev", executablePath],
135+
{
136+
encoding: "utf8",
137+
timeout: 5_000,
138+
},
139+
)
140+
141+
expect(result.status).not.toBe(0)
142+
expect(`${result.stdout}${result.stderr}`).toContain("Failed to launch desktop app:")
143+
expect(`${result.stdout}${result.stderr}`).toContain(executablePath)
144+
} finally {
145+
rmSync(dir, { recursive: true, force: true })
146+
}
147+
},
148+
)
140149
})

0 commit comments

Comments
 (0)