Files
orca/config/scripts/test-runtime/node-worker/vitest-node-runtime-boundary.test.ts
T
Neil 9bd6272fdf refactor(tooling): organize build, CI, and test owners (#38130)
* refactor(tooling): organize test runtime and maintenance owners

* test(tooling): preserve relocated runtime fixture dependency edges

* refactor(tooling): preserve xterm routing owner checks

* ci(tooling): include routing owner in sparse checkout

* test(tooling): preserve copied workflow dependency closures

* fix(tooling): normalize hashed JSON assets in release parity

* fix(tooling): distinguish asset aliases from literal references

* fix(tooling): frame normalized asset reference payloads

* fix(tooling): normalize decoded JSON asset references

* refactor(tooling): organize build, CI and release owners

* fix(tooling): align moved generator and workflow path contracts

* fix(tooling): update generated plugin bundle owner banners

* test(tooling): create relocated mobile verifier fixture directories

* test(tooling): copy headless detector dependency closure

* test(tooling): align native batch policy fixtures with owner path

* fix(tooling): link moved reliability command to historical evidence

* fix(tooling): preserve nested sandbox owners and canonical guide source

* fix(tooling): target release version owners in checkout fixture
2026-11-04 21:08:19 -08:00

61 lines
2.1 KiB
TypeScript

import { globSync, readFileSync } from 'node:fs'
import { resolve } from 'node:path'
import ts from 'typescript-api'
import { expect, it } from 'vitest'
import { discoverUnitFiles } from '../../ci/unit-selection/dependency-graph/ci-unit-files.mjs'
import { getNodeRuntimeInclude } from '../sqlite-admission/vitest-node-runtime-files.mjs'
it('runs Node runtime contracts in Node even when the coordinator uses Bun', () => {
expect(process.versions.bun).toBeUndefined()
expect(process.release.name).toBe('node')
expect(Number(process.versions.node.split('.')[0])).toBeGreaterThanOrEqual(24)
})
function isGlobalThis(expression: ts.Expression): boolean {
if (
ts.isParenthesizedExpression(expression) ||
ts.isAsExpression(expression) ||
ts.isSatisfiesExpression(expression) ||
ts.isNonNullExpression(expression)
) {
return isGlobalThis(expression.expression)
}
return ts.isIdentifier(expression) && expression.text === 'globalThis'
}
it('keeps exposed-GC heap measurements in the Node runtime project', () => {
const root = process.cwd()
const nodeFiles = new Set(globSync(getNodeRuntimeInclude()).map((file) => resolve(root, file)))
const missing: string[] = []
for (const file of discoverUnitFiles(root)) {
if (nodeFiles.has(resolve(root, file))) {
continue
}
const source = readFileSync(resolve(root, file), 'utf8')
if (!source.includes('heapUsed') || !source.includes('gc')) {
continue
}
const module = ts.createSourceFile(file, source, ts.ScriptTarget.Latest)
let usesGlobalGc = false
const visit = (node: ts.Node): void => {
if (
(ts.isPropertyAccessExpression(node) &&
node.name.text === 'gc' &&
isGlobalThis(node.expression)) ||
(ts.isElementAccessExpression(node) &&
ts.isStringLiteral(node.argumentExpression) &&
node.argumentExpression.text === 'gc' &&
isGlobalThis(node.expression))
) {
usesGlobalGc = true
}
ts.forEachChild(node, visit)
}
visit(module)
if (usesGlobalGc) {
missing.push(file)
}
}
expect(missing).toEqual([])
})