mirror of
https://github.com/stablyai/orca.git
synced 2026-10-28 00:02:54 +00:00
test(orcad): assert the precondition is self-consistent, not environment-shaped
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.
This commit is contained in:
@@ -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}`
|
||||
|
||||
Reference in New Issue
Block a user