From 9dd6386798a1fc834f1558b4916319571de86dca Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Mon, 24 Aug 2026 23:14:55 -0700 Subject: [PATCH] test(orcad): assert the precondition is self-consistent, not environment-shaped MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The real-host case cannot predict a status: CI's shard runs vitest directly, so node-pty is never built for the Node ABI and 'degraded' is correct there, while a prepared checkout gives 'ok'. The previous attempt used require('node-pty') as ground truth, which resolves the JS wrapper while the native binding loads lazily — it proved strictly less than the precondition checks, and failed CI for exactly that reason. What is invariant on a host with node-pty installed: never 'blocked', and never a degraded verdict carrying an unestablished reason. The injected-input tests keep the logic coverage. --- src/main/orcad/node-pty-precondition.test.ts | 32 +++++++++++--------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/main/orcad/node-pty-precondition.test.ts b/src/main/orcad/node-pty-precondition.test.ts index f5b567ae9ec..ee2194aaefe 100644 --- a/src/main/orcad/node-pty-precondition.test.ts +++ b/src/main/orcad/node-pty-precondition.test.ts @@ -179,21 +179,25 @@ describe('checkNodePtyPrecondition', () => { expect(verdict).toMatchObject({ status: 'blocked', reason: 'dependency_missing' }) }) - it('agrees with whether node-pty actually loads on this host', () => { - // Why compared against ground truth rather than asserted as 'ok': CI's test shard - // runs `vitest` directly, so `ensure-native-runtime --runtime=node` never prepares - // node-pty for the Node ABI and `degraded` is the CORRECT verdict there. Asserting - // 'ok' encoded a prepared environment the shard does not have. Asserting "whatever - // it said" would be vacuous, so this pins the verdict to an independent check. - let loads = true - try { - createRequire(import.meta.url)('node-pty') - } catch { - loads = false - } - + it('returns a self-consistent verdict against the real host', () => { + // Why not a predicted status: this depends on how the host was prepared. CI's test + // shard runs `vitest` directly, so `ensure-native-runtime --runtime=node` never + // builds node-pty for the Node ABI and `degraded` is correct there; a prepared + // checkout gives 'ok'. Predicting either encodes an environment. + // + // Why not require('node-pty') as ground truth: that resolves the JS wrapper while + // the native binding loads lazily, so it proves strictly less than this checks — + // that was the first version of this test and it failed on CI for that reason. + // + // What is invariant: on a host where node-pty is installed at all, the verdict is + // never 'blocked' and never carries an unestablished reason. const verdict = checkNodePtyPrecondition({ prebuildsDir: null }) - expect(verdict.status).toBe(loads ? 'ok' : 'degraded') + + expect(['ok', 'degraded']).toContain(verdict.status) + if (verdict.status === 'degraded') { + expect(verdict.reason).toBeDefined() + expect(verdict.reason).not.toBe('unknown') + } expect(verdict.slot).toBe( process.platform === 'linux' ? `linux-${process.arch}-${verdict.abi.libc}`