mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
* test: remove low-value runtime packaging and diagnostic suites * test: clear scan-progress listeners after AI Vault IPC cases --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
46 lines
1.5 KiB
JavaScript
46 lines
1.5 KiB
JavaScript
import { mkdir, mkdtemp, writeFile } from 'node:fs/promises'
|
|
import { createRequire } from 'node:module'
|
|
import { tmpdir } from 'node:os'
|
|
import { join } from 'node:path'
|
|
import { describe, expect, it } from 'vitest'
|
|
import { removeTree } from '../../../../src/shared/windows-transient-lock-removal.ts'
|
|
|
|
const require = createRequire(import.meta.url)
|
|
const {
|
|
assertNoWindowsExecutablesInRuntimeNodeModules
|
|
} = require('../../../packaged-windows-only-runtime-files.cjs')
|
|
|
|
async function withTempDir(prefix, run) {
|
|
const dir = await mkdtemp(join(tmpdir(), prefix))
|
|
try {
|
|
await run(dir)
|
|
} finally {
|
|
await removeTree(dir)
|
|
}
|
|
}
|
|
|
|
function peImage() {
|
|
const image = Buffer.alloc(0x80)
|
|
image.write('MZ', 0, 'latin1')
|
|
image.writeUInt32LE(0x40, 0x3c)
|
|
image.write('PE\0\0', 0x40, 'latin1')
|
|
image.writeUInt16LE(0x14c, 0x44)
|
|
return image
|
|
}
|
|
|
|
describe('Windows-only runtime files', () => {
|
|
it('fails a non-Windows package that ships a Windows executable under any name', async () => {
|
|
await withTempDir('orca-windows-exe-', async (resourcesDir) => {
|
|
const nested = join(resourcesDir, 'node_modules', 'some-dep', 'bin')
|
|
await mkdir(nested, { recursive: true })
|
|
await writeFile(join(nested, 'helper'), peImage())
|
|
expect(() => assertNoWindowsExecutablesInRuntimeNodeModules(resourcesDir, 'linux')).toThrow(
|
|
/: node_modules\/some-dep\/bin\/helper\. /
|
|
)
|
|
expect(() =>
|
|
assertNoWindowsExecutablesInRuntimeNodeModules(resourcesDir, 'win32')
|
|
).not.toThrow()
|
|
})
|
|
})
|
|
})
|