Files
archived-orca/src/main/node-runtime/appimage-bundled-node-runtime.test.ts
T
OrcaWinandm4air 49a1129aa6 build(linux): carry the pinned Node inside the AppImage so serve's slot works offline (#28204)
* build(linux): carry the pinned Node inside the AppImage so orca serve's slot works offline

Linux packaging places the pinned glibc Node at resources/node-runtime/bin/node before the
glibc-floor gate, proves it serves one PTY with the packaged daemon entry, and deb/rpm exclude
it through fpm. orca serve's orcad slot copies that Node (hash-checked) instead of downloading.

* test(serve): type the bundled Node fixture

---------

Co-authored-by: m4air <m4air@Mac.localdomain>
2026-10-13 00:39:39 -07:00

43 lines
1.4 KiB
TypeScript

import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
import { NODE_RUNTIME_ASSETS } from '../../shared/node-runtime-pin'
import { findAppImageNodeRuntime } from './appimage-bundled-node-runtime'
let resources = ''
beforeEach(() => {
resources = mkdtempSync(join(tmpdir(), 'orca-appimage-node-'))
})
afterEach(() => {
rmSync(resources, { recursive: true, force: true })
})
function bundle(): string {
const path = join(resources, 'node-runtime', 'bin', 'node')
mkdirSync(join(path, '..'), { recursive: true })
writeFileSync(path, '')
return path
}
describe('findAppImageNodeRuntime', () => {
it('names the pinned glibc Node a Linux package carries for its CPU', () => {
const path = bundle()
expect(findAppImageNodeRuntime(resources, 'arm64', 'linux')).toEqual({
path,
target: 'linux-arm64-glibc',
executableSha256: NODE_RUNTIME_ASSETS['linux-arm64-glibc'].executableSha256
})
})
it('finds nothing in a package without one, or off Linux', () => {
expect(findAppImageNodeRuntime(resources, 'x64', 'linux')).toBeNull()
bundle()
expect(findAppImageNodeRuntime(resources, 'x64', 'darwin')).toBeNull()
expect(findAppImageNodeRuntime(resources, 'ia32', 'linux')).toBeNull()
expect(findAppImageNodeRuntime(undefined, 'x64', 'linux')).toBeNull()
})
})