From bd49fcc3cdf2564b1cf7c1001c4ccf702e254235 Mon Sep 17 00:00:00 2001 From: Menghuan1918 Date: Fri, 14 Aug 2026 16:54:50 +0800 Subject: [PATCH] ci: restrict spawn-helper test to macOS, its only platform node-pty@1.1.0 builds the spawn-helper executable only for OS=="mac" (binding.gyp); linux uses forkpty directly and ships no helper at all. The test's non-Windows premise was wrong for linux, and no candidate exists there to assert on. --- tests/unit.spec.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/unit.spec.ts b/tests/unit.spec.ts index cdab6dd..1202387 100644 --- a/tests/unit.spec.ts +++ b/tests/unit.spec.ts @@ -861,8 +861,10 @@ describe('pty helpers', () => { }) it('restores the spawn-helper executable bit idempotently', () => { - // On non-Windows the helper must exist and be executable after the fix. - if (process.platform === 'win32') return + // node-pty's spawn-helper is a macOS-only artifact: binding.gyp builds + // the executable only for OS=="mac", and no other platform ships one to + // restore (linux uses forkpty directly). Skip elsewhere. + if (process.platform !== 'darwin') return ensureSpawnHelper() ensureSpawnHelper() const { existsSync, statSync } = require('node:fs') as typeof import('node:fs') @@ -870,9 +872,8 @@ describe('pty helpers', () => { const { createRequire } = require('node:module') as typeof import('node:module') const entry = createRequire(import.meta.url).resolve('node-pty') const root = dirname(dirname(entry)) - // node-pty ships a prebuilt spawn-helper for darwin/win32; on other - // platforms (linux) node-gyp compiles it into build/Release. Mirror - // ensureSpawnHelper's candidate list: either location is acceptable. + // Prebuilt (tarball) or node-gyp-compiled (build/Release): mirror + // ensureSpawnHelper's candidate list — either location is acceptable. const candidates = [ join(root, 'prebuilds', `${process.platform}-${process.arch}`, 'spawn-helper'), join(root, 'build', 'Release', 'spawn-helper'),