From a820de5ff51713d40b8ce3dc153cdfca2430d698 Mon Sep 17 00:00:00 2001 From: OrcaWin Date: Thu, 5 Nov 2026 11:11:42 -0800 Subject: [PATCH] test: remove 91 low-value terminal and compiler tests (#38623) Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com> --- .github/workflows/pr.yml | 2 - .../scripts/ci/sharding/ci-shard-timings.json | 15 - ...xterm-image-cell-payload-contract.test.mjs | 235 ------------- .../xterm-image-lifecycle-contract.test.mjs | 162 +-------- .../xterm-image-memory-contract.test.mjs | 57 --- .../xterm-image-resize-contract.test.mjs | 40 --- .../xterm-image-wasm-budget-contract.test.mjs | 36 -- .../xterm-underline-color-contract.test.mjs | 29 -- .../vitest-run-filters.test.mjs | 53 --- .../vitest-node-runtime-boundary.test.ts | 60 ---- .../vitest-node-runtime-files.mjs | 1 - .../oxc-cli-invocation.test.mjs | 39 --- .../e2e-admission/run-e2e-typecheck.test.mjs | 119 ------- .../agent-typescript-lsp.test.mjs | 137 -------- ...un-typecheck-projects-in-parallel.test.mjs | 331 +----------------- .../tsrs-typecheck-compiler.test.mjs | 137 -------- .../typecheck-project-coverage.test.mjs | 72 ---- .../pdfjs-viewer-assets-stream.test.ts | 72 ---- .../pr-ready-check-reuse.test.mjs | 174 --------- ...code-change-scope-daemon-protocol.test.mjs | 23 -- ...pr-code-change-scope-process-host.test.mjs | 29 -- .../pr-code-change-scope-test-inputs.test.mjs | 42 --- ...hange-scope-windows-process-probe.test.mjs | 36 -- 23 files changed, 4 insertions(+), 1897 deletions(-) delete mode 100644 config/scripts/terminal-dependencies/xterm-patches/xterm-image-cell-payload-contract.test.mjs delete mode 100644 config/scripts/terminal-dependencies/xterm-patches/xterm-image-resize-contract.test.mjs delete mode 100644 config/scripts/terminal-dependencies/xterm-patches/xterm-underline-color-contract.test.mjs delete mode 100644 config/scripts/test-runtime/execution-policy/vitest-run-filters.test.mjs delete mode 100644 config/scripts/test-runtime/node-worker/vitest-node-runtime-boundary.test.ts delete mode 100644 config/scripts/tool-invocation/oxc-cli-invocation.test.mjs delete mode 100644 config/scripts/typecheck/e2e-admission/run-e2e-typecheck.test.mjs delete mode 100644 config/scripts/typecheck/language-server/agent-typescript-lsp.test.mjs delete mode 100644 config/scripts/typecheck/project-execution/tsrs-typecheck-compiler.test.mjs delete mode 100644 config/scripts/typecheck/project-execution/typecheck-project-coverage.test.mjs delete mode 100644 config/scripts/workflow/pr-admission/pr-ready-check-reuse.test.mjs delete mode 100644 config/scripts/workflow/source-routing/pr-code-change-scope-daemon-protocol.test.mjs delete mode 100644 config/scripts/workflow/source-routing/pr-code-change-scope-process-host.test.mjs delete mode 100644 config/scripts/workflow/source-routing/pr-code-change-scope-test-inputs.test.mjs delete mode 100644 config/scripts/workflow/source-routing/pr-code-change-scope-windows-process-probe.test.mjs diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index def79085fbb..fec9984f67a 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -567,9 +567,7 @@ jobs: --maxWorkers=4 --isolate --retry=0 --bail=0 config/scripts/mobile-web/check-entry/mobile-release-check-scope.test.mjs config/scripts/mobile-web/check-entry/mobile-test-change-scope.test.mjs - config/scripts/workflow/pr-admission/pr-ready-check-reuse.test.mjs config/scripts/ci/unit-selection/win32-test-lane-registration.test.mjs - config/scripts/test-runtime/node-worker/vitest-node-runtime-boundary.test.ts config/scripts/test-runtime/sqlite-admission/vitest-sqlite-runtime-boundary.test.ts # Report failure through the separate required check without blocking unrelated consumers. diff --git a/config/scripts/ci/sharding/ci-shard-timings.json b/config/scripts/ci/sharding/ci-shard-timings.json index c708f4dabe1..a5265de0533 100644 --- a/config/scripts/ci/sharding/ci-shard-timings.json +++ b/config/scripts/ci/sharding/ci-shard-timings.json @@ -16,7 +16,6 @@ "config/scripts/release/workflow-contracts/adhoc-build-pinned-commit.test.mjs": 375, "config/scripts/desktop-distribution/macos/adhoc-mac-manifests.test.mjs": 112, "config/scripts/release/workflow-contracts/adhoc-release-waits.test.mjs": 151, - "config/scripts/typecheck/language-server/agent-typescript-lsp.test.mjs": 116, "config/scripts/static-analysis/oxlint-contracts/app-store-performance-plugin.test.mjs": 339, "config/scripts/desktop-distribution/linux/appimage-node-runtime.test.mjs": 146, "config/scripts/localization/source-extraction/audit-localization-coverage.test.mjs": 140, @@ -240,7 +239,6 @@ "config/scripts/orcad-distribution/server-bundle/orcad-watcher-package.test.mjs": 94, "config/scripts/orcad-distribution/server-bundle/orcad-windows-cli-launcher.test.mjs": 94, "config/scripts/orcad-distribution/prebuilds/orcad-windows-prebuild-cache.test.mjs": 18343, - "config/scripts/tool-invocation/oxc-cli-invocation.test.mjs": 139, "config/scripts/desktop-distribution/runtime-verification/package-electron-runtime-contract.test.mjs": 220, "config/scripts/desktop-distribution/linux/package-linux-formats-appimage.test.mjs": 624, "config/scripts/desktop-distribution/linux/package-linux-formats.test.mjs": 282, @@ -262,19 +260,14 @@ "config/scripts/ci/workflow-contracts/pr-auxiliary-preflight-admission.test.mjs": 2174, "config/scripts/workflow/source-routing/pr-code-change-scope-cross-version-launch-route.test.mjs": 54, "config/scripts/workflow/source-routing/pr-code-change-scope-cross-version-send-path.test.mjs": 71, - "config/scripts/workflow/source-routing/pr-code-change-scope-daemon-protocol.test.mjs": 46, "config/scripts/workflow/source-routing/pr-code-change-scope-format-route.test.mjs": 155, - "config/scripts/workflow/source-routing/pr-code-change-scope-process-host.test.mjs": 57, "config/scripts/workflow/source-routing/pr-code-change-scope-released-phone.test.mjs": 76, - "config/scripts/workflow/source-routing/pr-code-change-scope-test-inputs.test.mjs": 61, - "config/scripts/workflow/source-routing/pr-code-change-scope-windows-process-probe.test.mjs": 67, "config/scripts/workflow/source-routing/pr-code-change-scope.test.mjs": 403, "config/scripts/workflow/source-routing/pr-codex-unit-only-selection.test.mjs": 53, "config/scripts/workflow/source-routing/pr-e2e-gate-contract.test.mjs": 270, "config/scripts/ci/e2e-selection/pr-e2e-managed-ssh-harness-route.test.mjs": 422, "config/scripts/ci/e2e-selection/pr-plugin-e2e-routing.test.mjs": 272, "config/scripts/workflow/pr-admission/pr-ready-check-gate.test.mjs": 1343, - "config/scripts/workflow/pr-admission/pr-ready-check-reuse.test.mjs": 179, "config/scripts/ci/workflow-contracts/pr-test-loc-summary.test.mjs": 167, "config/scripts/workflow/source-routing/pr-unit-support-routing.test.mjs": 14771, "config/scripts/ci/workflow-contracts/pr-workflow-parallelism.test.mjs": 161, @@ -320,7 +313,6 @@ "config/scripts/archives/seven-zip/resolve-7za-path.test.mjs": 1391, "config/scripts/dependency-security/audit-tools/run-audit-tool.test.mjs": 131, "config/scripts/runtime-verification/codex-account/run-codex-real-account-validation.test.ts": 3083, - "config/scripts/typecheck/e2e-admission/run-e2e-typecheck.test.mjs": 1147, "config/scripts/development/setup/run-internal-dev-setup.test.mjs": 50, "config/scripts/desktop-distribution/runtime-verification/run-linux-packaged-node-pty-floor-smoke.test.mjs": 169, "config/scripts/typecheck/project-execution/run-typecheck-bun-queue.test.mjs": 595, @@ -345,8 +337,6 @@ "config/scripts/performance/terminal-reporting/terminal-perf-report-annotations.test.mjs": 54, "config/scripts/static-analysis/process-boundaries/test-only-source-path.test.mjs": 38, "config/scripts/desktop-distribution/windows/trim-windows-icon-source.test.mjs": 353, - "config/scripts/typecheck/project-execution/tsrs-typecheck-compiler.test.mjs": 719, - "config/scripts/typecheck/project-execution/typecheck-project-coverage.test.mjs": 689, "config/scripts/dependency-security/runtime-resolution/undeclared-dependency-resolution.test.ts": 149, "config/scripts/node-runtime/archive-identity/update-node-runtime-pin.test.mjs": 87, "config/scripts/plugin-authoring/content-validation/validate-plugin-files.test.mjs": 2422, @@ -371,10 +361,8 @@ "config/scripts/runtime-verification/participation/verify-wsl-e2e-participation.test.mjs": 57, "config/scripts/test-runtime/execution-policy/vitest-changed-precheck.test.mjs": 46, "config/scripts/test-runtime/module-cache/vitest-module-cache-resolution-key.test.ts": 50, - "config/scripts/test-runtime/node-worker/vitest-node-runtime-boundary.test.ts": 2885, "config/scripts/test-runtime/node-worker/vitest-node-runtime-pool.test.ts": 560, "config/scripts/test-runtime/environment/vitest-real-agent-home-write-guard.test.ts": 71, - "config/scripts/test-runtime/execution-policy/vitest-run-filters.test.mjs": 146, "config/scripts/test-runtime/execution-policy/vitest-run-temp-directory.test.mjs": 51, "config/scripts/test-runtime/environment/vitest-runtime-boundary.test.ts": 454, "config/scripts/test-runtime/execution-policy/vitest-runtime-sequencer.test.mjs": 186, @@ -400,7 +388,6 @@ "config/scripts/workspace/source-exports/workspace-source-exports.test.mjs": 117, "config/scripts/workflow/source-routing/wsl-e2e-lane-contract.test.mjs": 235, "config/scripts/release/workflow-contracts/wsl-orcad-qualification-shell.test.mjs": 133, - "config/scripts/terminal-dependencies/xterm-patches/xterm-image-cell-payload-contract.test.mjs": 110, "config/scripts/terminal-dependencies/xterm-patches/xterm-image-kitty-admission.test.mjs": 1430, "config/scripts/terminal-dependencies/xterm-patches/xterm-image-kitty-coordinate-boundaries.test.mjs": 191, "config/scripts/terminal-dependencies/xterm-patches/xterm-image-kitty-file-transport.test.mjs": 404, @@ -410,9 +397,7 @@ "config/scripts/terminal-dependencies/xterm-patches/xterm-image-kitty-retransmit.test.mjs": 835, "config/scripts/terminal-dependencies/xterm-patches/xterm-image-lifecycle-contract.test.mjs": 174, "config/scripts/terminal-dependencies/xterm-patches/xterm-image-memory-contract.test.mjs": 368, - "config/scripts/terminal-dependencies/xterm-patches/xterm-image-resize-contract.test.mjs": 65, "config/scripts/terminal-dependencies/xterm-patches/xterm-image-wasm-budget-contract.test.mjs": 469, - "config/scripts/terminal-dependencies/xterm-patches/xterm-underline-color-contract.test.mjs": 60, "config/scripts/ci/workflow-contracts/zcode-credential-workflow.test.mjs": 668, "config/scripts/archives/platform-command/zip-extractor-command.test.mjs": 74, "src/cli/account-add-process.test.ts": 33700, diff --git a/config/scripts/terminal-dependencies/xterm-patches/xterm-image-cell-payload-contract.test.mjs b/config/scripts/terminal-dependencies/xterm-patches/xterm-image-cell-payload-contract.test.mjs deleted file mode 100644 index 793ccf6390a..00000000000 --- a/config/scripts/terminal-dependencies/xterm-patches/xterm-image-cell-payload-contract.test.mjs +++ /dev/null @@ -1,235 +0,0 @@ -import { createRequire } from 'node:module' -import { afterEach, describe, expect, it, vi } from 'vitest' - -const require = createRequire( - new URL('../../xterm-image-cell-payload-contract.test.mjs', import.meta.url) -) -const { Terminal } = require('@xterm/xterm') -const { ImageAddon } = require('@xterm/addon-image') - -function createTerminal(cols = 6) { - vi.stubGlobal('window', {}) - const terminal = new Terminal({ cols, rows: 4, scrollback: 20, allowProposedApi: true }) - const addon = new ImageAddon({ enableSizeReports: false, storageLimit: 32 }) - terminal.loadAddon(addon) - vi.spyOn(addon._renderer, 'cellSize', 'get').mockReturnValue({ width: 7, height: 14 }) - return { terminal, storage: addon._storage } -} - -function write(terminal, data) { - return new Promise((resolve) => terminal.write(data, resolve)) -} - -function place(storage, cols = 1) { - const image = { width: cols * 7, height: 14 } - const id = storage.addImage(image, { - scrolling: true, - layer: 'top', - zIndex: 0, - cursorPos: 'iip' - }) - return { image, id } -} - -function line(terminal, row = 0) { - return terminal._core.buffer.lines.get(row) -} - -function cells(terminal) { - const result = [] - for (let row = 0; row < terminal._core.buffer.lines.length; row++) { - for (let col = 0; col < terminal.cols; col++) { - const payload = line(terminal, row).getExtended(col).payload - if (payload !== undefined) { - result.push({ row, col, payload }) - } - } - } - return result -} - -afterEach(() => vi.unstubAllGlobals()) - -describe('installed xterm image cell payload contract', () => { - it('isolates image tiles from shared hyperlink attributes and unrelated payloads', async () => { - const { terminal, storage } = createTerminal() - try { - await write(terminal, '\x1b[1;31;44m\x1b]8;id=shared;https://example.test\x1b\\ABC') - const bufferLine = line(terminal) - const shared = bufferLine.getExtended(1) - expect(bufferLine.getExtended(2)).toBe(shared) - const before = [1, 2].map((col) => ({ - text: terminal.buffer.active.getLine(0).getCell(col).getChars(), - width: terminal.buffer.active.getLine(0).getCell(col).getWidth(), - fg: bufferLine.getFg(col), - bg: bufferLine.getBg(col) - })) - const unrelated = { kind: 'other-addon' } - const cell = terminal.buffer.active.getLine(0).getCell(0) - cell.extended = cell.extended.clone() - cell.extended.payload = unrelated - cell.updateExtended() - bufferLine.setCell(0, cell) - await write(terminal, '\x1b[1;2H') - const placed = place(storage, 2) - for (const [index, col] of [1, 2].entries()) { - const current = terminal.buffer.active.getLine(0).getCell(col) - expect(current.getChars()).toBe(before[index].text) - expect(current.getWidth()).toBe(before[index].width) - expect(bufferLine.getFg(col)).toBe(before[index].fg) - expect(bufferLine.getBg(col)).toBe(before[index].bg) - expect(bufferLine.getExtended(col).urlId).toBe(shared.urlId) - expect(bufferLine.getExtended(col).payload).toMatchObject({ - imageId: placed.id, - tileId: index - }) - expect(storage.getImageAtBufferCell(col, 0)).toBe(placed.image) - } - expect(bufferLine.getExtended(1)).not.toBe(bufferLine.getExtended(2)) - expect(shared.payload).toBeUndefined() - expect(bufferLine.getExtended(0).payload).toBe(unrelated) - expect(bufferLine.getExtended(0).isEmpty()).toBe(false) - expect(storage.getImageAtBufferCell(0, 0)).toBeUndefined() - await write(terminal, '\x1b[1;2H') - const replacement = place(storage) - expect(storage.getImageAtBufferCell(1, 0)).toBe(replacement.image) - expect(storage.getImageAtBufferCell(2, 0)).toBe(placed.image) - expect(bufferLine.getExtended(2).payload).toMatchObject({ imageId: placed.id, tileId: 1 }) - } finally { - terminal.dispose() - } - }) - - it('retains wide and combining text when physical tiles are attached', async () => { - const { terminal, storage } = createTerminal() - try { - await write(terminal, 'A界e\u0301😀\x1b[1;2H') - const placed = place(storage, 3) - const publicLine = terminal.buffer.active.getLine(0) - expect(publicLine.getCell(1).getChars()).toBe('界') - expect(publicLine.getCell(1).getWidth()).toBe(2) - expect(publicLine.getCell(2).getWidth()).toBe(0) - expect(publicLine.getCell(3).getChars()).toBe('e\u0301') - expect(publicLine.getCell(3).getWidth()).toBe(1) - expect(publicLine.getCell(4).getChars()).toBe('😀') - for (let col = 1; col <= 3; col++) { - expect(storage.getImageAtBufferCell(col, 0)).toBe(placed.image) - } - expect(cells(terminal)).toHaveLength(3) - } finally { - terminal.dispose() - } - }) - - it('moves tiles through insert/delete without leaking reused cell attributes', async () => { - const { terminal, storage } = createTerminal() - try { - await write(terminal, 'ABC\x1b[1;2H') - const placed = place(storage) - await write(terminal, '\x1b[1;1H\x1b[@') - expect(storage.getImageAtBufferCell(2, 0)).toBe(placed.image) - expect(line(terminal).getExtended(0).payload).toBeUndefined() - expect(line(terminal).getExtended(1).payload).toBeUndefined() - await write(terminal, '\x1b[P') - expect(storage.getImageAtBufferCell(1, 0)).toBe(placed.image) - expect(cells(terminal)).toHaveLength(1) - await write(terminal, '\x1b[1;2H\x1b[0mX\x1b[2;1Hordinary') - expect(terminal.buffer.active.getLine(0).getCell(1).getChars()).toBe('X') - // Precondition: the stale map entry survives, so the next line proves the flag gates it. - expect(line(terminal)._extendedAttrs[1].payload.imageId).toBe(placed.id) - expect(line(terminal).getExtended(1).payload).toBeUndefined() - expect(storage.getImageAtBufferCell(1, 0)).toBeUndefined() - expect(cells(terminal)).toEqual([]) - } finally { - terminal.dispose() - } - }) - - it('preserves tile identity and source lookup across shrink and growth reflow', async () => { - const { terminal, storage } = createTerminal(4) - try { - await write(terminal, 'ABCDEF\x1b[1;3H') - const placed = place(storage, 2) - await write(terminal, '\x1b[3;1H') - terminal.resize(3, 4) - expect( - cells(terminal).map(({ row, col, payload }) => [row, col, payload.imageId, payload.tileId]) - ).toEqual([ - [0, 2, placed.id, 0], - [1, 0, placed.id, 1] - ]) - expect(storage.getImageAtBufferCell(2, 0)).toBe(placed.image) - expect(storage.getImageAtBufferCell(0, 1)).toBe(placed.image) - terminal.resize(4, 4) - expect( - cells(terminal).map(({ row, col, payload }) => [row, col, payload.imageId, payload.tileId]) - ).toEqual([ - [0, 2, placed.id, 0], - [0, 3, placed.id, 1] - ]) - expect(terminal.buffer.active.getLine(0).translateToString(true)).toBe('ABCD') - expect(terminal.buffer.active.getLine(1).translateToString(true)).toBe('EF') - } finally { - terminal.dispose() - } - }) - - it('isolates alternate-screen payloads and restores the normal image', async () => { - const { terminal, storage } = createTerminal() - try { - const normal = place(storage) - await write(terminal, '\x1b[?1049h\x1b[H') - expect(cells(terminal)).toEqual([]) - const alternate = place(storage) - expect(storage.getImageAtBufferCell(0, 0)).toBe(alternate.image) - await write(terminal, '\x1b[?1049l') - expect(storage.getImageAtBufferCell(0, 0)).toBe(normal.image) - expect(cells(terminal)).toHaveLength(1) - expect(cells(terminal)[0].payload.imageId).toBe(normal.id) - await write(terminal, '\x1b[?1049h') - expect(cells(terminal)).toEqual([]) - expect(storage.getImageAtBufferCell(0, 0)).toBeUndefined() - } finally { - terminal.dispose() - } - }) - - it('replaces a foreign payload with a fresh tile without mutating it', async () => { - const { terminal, storage } = createTerminal() - try { - await write(terminal, '\x1b]8;;https://example.test\x1b\\AB') - const bufferLine = line(terminal) - const foreign = { kind: 'other-addon' } - const cell = terminal.buffer.active.getLine(0).getCell(0) - cell.extended = cell.extended.clone() - cell.extended.payload = foreign - cell.updateExtended() - bufferLine.setCell(0, cell) - const foreignAttrs = bufferLine.getExtended(0) - await write(terminal, '\x1b[1;1H') - const placed = place(storage) - expect(foreign).toEqual({ kind: 'other-addon' }) - expect(foreignAttrs.payload).toBe(foreign) - expect(bufferLine.getExtended(0)).not.toBe(foreignAttrs) - expect(bufferLine.getExtended(0).urlId).toBe(foreignAttrs.urlId) - expect(bufferLine.getExtended(0).payload).toMatchObject({ imageId: placed.id, tileId: 0 }) - expect(storage.getImageAtBufferCell(0, 0)).toBe(placed.image) - } finally { - terminal.dispose() - } - }) - - it('never reports a payload for plain cells, even after a caller writes the shared blank', async () => { - const { terminal } = createTerminal() - try { - await write(terminal, 'AB') - const bufferLine = line(terminal) - // Plain cells share one scratch ExtendedAttrs; a stray write must not reach the next read. - bufferLine.getExtended(0).payload = { kind: 'stray' } - expect(bufferLine.getExtended(1).payload).toBeUndefined() - expect(terminal.buffer.active.getLine(0).getCell(1).extended.payload).toBeUndefined() - } finally { - terminal.dispose() - } - }) -}) diff --git a/config/scripts/terminal-dependencies/xterm-patches/xterm-image-lifecycle-contract.test.mjs b/config/scripts/terminal-dependencies/xterm-patches/xterm-image-lifecycle-contract.test.mjs index 4d4c6ebb565..77e69c9e430 100644 --- a/config/scripts/terminal-dependencies/xterm-patches/xterm-image-lifecycle-contract.test.mjs +++ b/config/scripts/terminal-dependencies/xterm-patches/xterm-image-lifecycle-contract.test.mjs @@ -1,5 +1,5 @@ import { createRequire } from 'node:module' -import { crc32, deflateRawSync, deflateSync } from 'node:zlib' +import { crc32, deflateSync } from 'node:zlib' import { afterEach, describe, expect, it, vi } from 'vitest' const require = createRequire( @@ -30,89 +30,6 @@ function createTerminal() { afterEach(() => vi.unstubAllGlobals()) describe('xterm image allocation lifecycle', () => { - it('closes alternate-buffer bitmaps when images are reset', async () => { - const { terminal, addon, storage } = createTerminal() - try { - await new Promise((resolve) => terminal.write('\x1b[?1049h', resolve)) - const bitmap = new TrackedBitmap() - storage.addImage(bitmap, { scrolling: true, layer: 'top', zIndex: 0, cursorPos: 'iip' }) - expect(storage._images.size).toBe(1) - addon.reset() - expect(storage._images.size).toBe(0) - expect(bitmap.close).toHaveBeenCalledOnce() - } finally { - terminal.dispose() - } - }) - - it.each(['reset', 'dispose'])( - 'discards IIP decode that finishes after addon %s', - async (action) => { - const { terminal, addon, storage } = createTerminal() - try { - let finishDecode - vi.stubGlobal( - 'createImageBitmap', - () => - new Promise((resolve) => { - finishDecode = resolve - }) - ) - const iip = addon._handlers.get('iip') - const png = - 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIHWP4z8DwHwAFgAI/ScLbtAAAAABJRU5ErkJggg==' - const payload = Uint32Array.from(`File=inline=1:${png}`, (char) => char.codePointAt(0)) - iip.start() - iip.put(payload, 0, payload.length) - const decoding = iip.end(true) - expect(finishDecode).toBeTypeOf('function') - addon[action]() - const bitmap = new TrackedBitmap() - finishDecode(bitmap) - await decoding - expect(storage._images.size).toBe(0) - expect(bitmap.close).toHaveBeenCalledOnce() - } finally { - terminal.dispose() - } - } - ) - - it.each(['hide', 'dispose'])('closes placeholder bitmap finishing after %s', async (action) => { - const { terminal, addon } = createTerminal() - try { - const renderer = addon._renderer - const context = { - createImageData: (width, height) => ({ data: new Uint8ClampedArray(width * height * 4) }), - putImageData: () => {}, - drawImage: () => {} - } - vi.stubGlobal('document', { createElement: () => ({ getContext: () => context }) }) - vi.stubGlobal('screen', { width: 800 }) - let finishDecode - vi.stubGlobal( - 'createImageBitmap', - () => - new Promise((resolve) => { - finishDecode = resolve - }) - ) - renderer._createPlaceHolder(24) - if (action === 'dispose') { - addon.dispose() - } else { - renderer.showPlaceholder(false) - } - const bitmap = new TrackedBitmap() - finishDecode(bitmap) - await Promise.resolve() - expect(bitmap.close).toHaveBeenCalledOnce() - expect(renderer._placeholderBitmap).toBeUndefined() - } finally { - terminal.dispose() - } - }) - it('rejects oversized PNG headers before native bitmap allocation', async () => { const { terminal, kitty } = createTerminal() try { @@ -137,28 +54,6 @@ describe('xterm image allocation lifecycle', () => { } }) - it.each([deflateSync, deflateRawSync])( - 'preserves valid compressed image bytes (%#)', - async (compress) => { - const { terminal, kitty } = createTerminal() - try { - const original = Buffer.from([1, 2, 3, 4]) - expect(Buffer.from(await kitty._decompressZlib(compress(original)))).toEqual(original) - } finally { - terminal.dispose() - } - } - ) - - it('contains malformed compressed streams without unhandled writer rejections', async () => { - const { terminal, kitty } = createTerminal() - try { - await expect(kitty._decompressZlib(new Uint8Array([1, 2, 3, 4]))).rejects.toThrow() - } finally { - terminal.dispose() - } - }) - it('rejects compressed data expanding beyond the decoded-image budget', async () => { const { terminal, kitty } = createTerminal() try { @@ -173,59 +68,4 @@ describe('xterm image allocation lifecycle', () => { terminal.dispose() } }) - - it.each([{ x: 1 }, { columns: 2 }])( - 'discards Kitty image reset during crop or resize (%#)', - async (command) => { - const { terminal, addon, storage, kitty } = createTerminal() - try { - const original = new TrackedBitmap() - original.width = original.height = 10 - kitty._createBitmap = async () => original - let finishTransform - vi.stubGlobal( - 'createImageBitmap', - () => - new Promise((resolve) => { - finishTransform = resolve - }) - ) - const decoding = kitty._displayImage({ id: 1 }, command) - await Promise.resolve() - expect(finishTransform).toBeTypeOf('function') - addon.reset() - const transformed = new TrackedBitmap() - finishTransform(transformed) - await decoding - expect(storage._images.size).toBe(0) - expect(original.close).toHaveBeenCalledOnce() - expect(transformed.close).toHaveBeenCalledOnce() - } finally { - terminal.dispose() - } - } - ) - - it.each(['reset', 'dispose'])( - 'discards Kitty decode that finishes after addon %s', - async (action) => { - const { terminal, addon, storage, kitty } = createTerminal() - try { - let finishDecode - kitty._createBitmap = () => - new Promise((resolve) => { - finishDecode = resolve - }) - const decoding = kitty._displayImage({ id: 1 }, {}) - addon[action]() - const bitmap = new TrackedBitmap() - finishDecode(bitmap) - await decoding - expect(storage._images.size).toBe(0) - expect(bitmap.close).toHaveBeenCalledOnce() - } finally { - terminal.dispose() - } - } - ) }) diff --git a/config/scripts/terminal-dependencies/xterm-patches/xterm-image-memory-contract.test.mjs b/config/scripts/terminal-dependencies/xterm-patches/xterm-image-memory-contract.test.mjs index c180cd76a1e..8941e0acdcc 100644 --- a/config/scripts/terminal-dependencies/xterm-patches/xterm-image-memory-contract.test.mjs +++ b/config/scripts/terminal-dependencies/xterm-patches/xterm-image-memory-contract.test.mjs @@ -28,22 +28,6 @@ function writeKitty(terminal, command, payload) { } describe('xterm image memory contract', () => { - it('does not emit a reply when evicting an id-less upload', async () => { - const { terminal, handler } = createTerminal() - const replies = [] - terminal.onData((data) => replies.push(data)) - try { - await writeKitty(terminal, 'a=t,f=32,s=1,v=1,m=1', 'AAAA') - await writeKitty(terminal, 'a=t,f=32,s=1,v=1,i=1,m=1,q=2', 'AAAA') - await writeKitty(terminal, 'a=t,f=32,s=1,v=1,i=2,m=1,q=2', 'AAAA') - expect(handler._pendingTransmissions.has(0)).toBe(false) - expect(handler._pendingTransmissions.size).toBe(2) - expect(replies).toEqual([]) - } finally { - terminal.dispose() - } - }) - it('bounds abandoned uploads by retained decoder capacity and accepts a continuation', async () => { const { terminal, handler } = createTerminal() try { @@ -66,17 +50,6 @@ describe('xterm image memory contract', () => { } }) - it('rejects a decoder that cannot fit the storage budget before allocation', async () => { - const { terminal, handler } = createTerminal({ storageLimit: 8 }) - try { - await writeKitty(terminal, 'a=t,f=32,s=1,v=1,i=9,m=1,q=2', 'AAAA') - expect(handler._pendingTransmissions.size).toBe(0) - expect(handler._aborted).toBe(true) - } finally { - terminal.dispose() - } - }) - it('evicts transmitted images by byte size before placement', async () => { const { terminal, handler } = createTerminal({ storageLimit: 12, kittyStorageLimit: 0.5 }) const payload = Buffer.alloc(200_000, 1).toString('base64') @@ -98,34 +71,4 @@ describe('xterm image memory contract', () => { terminal.dispose() } }) - - it('evicts unplaced payloads before displayed ones', async () => { - const { terminal, handler } = createTerminal({ storageLimit: 12, kittyStorageLimit: 0.5 }) - const storage = handler._kittyStorage - const payload = Buffer.alloc(200_000, 1).toString('base64') - try { - await writeKitty(terminal, 'a=t,f=32,s=250,v=200,i=1,q=2', payload) - await writeKitty(terminal, 'a=t,f=32,s=250,v=200,i=2,q=2', payload) - // Placement bookkeeping only; a real addImage needs a canvas this env lacks. - storage._kittyIdToStorageId.set(1, 1001) - storage._storageIdToKittyId.set(1001, 1) - await writeKitty(terminal, 'a=t,f=32,s=250,v=200,i=3,q=2', payload) - expect(storage.getImage(1)).toBeDefined() - expect(storage.getImage(2)).toBeUndefined() - expect(storage.getImage(3).data.size).toBe(200_000) - } finally { - terminal.dispose() - } - }) - - it('stores an image larger than the byte budget rather than acking a dropped one', async () => { - const { terminal, handler } = createTerminal({ storageLimit: 12, kittyStorageLimit: 0.5 }) - const payload = Buffer.alloc(600_000, 1).toString('base64') - try { - await writeKitty(terminal, 'a=t,f=32,s=500,v=300,i=1,q=2', payload) - expect(handler._kittyStorage.getImage(1).data.size).toBe(600_000) - } finally { - terminal.dispose() - } - }) }) diff --git a/config/scripts/terminal-dependencies/xterm-patches/xterm-image-resize-contract.test.mjs b/config/scripts/terminal-dependencies/xterm-patches/xterm-image-resize-contract.test.mjs deleted file mode 100644 index 32467287c1a..00000000000 --- a/config/scripts/terminal-dependencies/xterm-patches/xterm-image-resize-contract.test.mjs +++ /dev/null @@ -1,40 +0,0 @@ -import { createRequire } from 'node:module' -import { afterEach, expect, it, vi } from 'vitest' - -const require = createRequire( - new URL('../../xterm-image-resize-contract.test.mjs', import.meta.url) -) -const { Terminal } = require('@xterm/xterm') -const { ImageAddon } = require('@xterm/addon-image') - -afterEach(() => vi.unstubAllGlobals()) - -it('scales visible tiles without allocating a full enlarged image on font zoom', () => { - const terminal = new Terminal({ allowProposedApi: true }) - const addon = new ImageAddon({ enableSizeReports: false, storageLimit: 32 }) - terminal.loadAddon(addon) - const createCanvas = vi.fn(() => ({ getContext: () => ({ drawImage: vi.fn() }) })) - vi.stubGlobal('document', { createElement: createCanvas }) - const renderer = addon._renderer - vi.spyOn(renderer, 'cellSize', 'get').mockReturnValue({ width: 90, height: 90 }) - const drawImage = vi.fn() - renderer._layers.set('top', { drawImage, clearRect() {}, canvas: { remove() {} } }) - const original = { width: 2000, height: 2000 } - const spec = { - orig: original, - actual: original, - origCellSize: { width: 10, height: 10 }, - actualCellSize: { width: 10, height: 10 }, - layer: 'top' - } - try { - renderer.draw(spec, 201, 2, 3) - expect(createCanvas).not.toHaveBeenCalled() - expect(drawImage).toHaveBeenCalledWith(original, 10, 10, 10, 10, 180, 270, 90, 90) - const tile = renderer.extractTile(spec, 201) - expect(tile.width).toBe(90) - expect(tile.height).toBe(90) - } finally { - terminal.dispose() - } -}) diff --git a/config/scripts/terminal-dependencies/xterm-patches/xterm-image-wasm-budget-contract.test.mjs b/config/scripts/terminal-dependencies/xterm-patches/xterm-image-wasm-budget-contract.test.mjs index 655fbe769ff..c185a05fb81 100644 --- a/config/scripts/terminal-dependencies/xterm-patches/xterm-image-wasm-budget-contract.test.mjs +++ b/config/scripts/terminal-dependencies/xterm-patches/xterm-image-wasm-budget-contract.test.mjs @@ -80,42 +80,6 @@ function firstPixel(image) { afterEach(() => vi.unstubAllGlobals()) describe('xterm image wasm budget', () => { - it('keeps idle terminals free of wasm decoders', async () => { - const panes = Array.from({ length: 300 }, () => createTerminal()) - try { - // Let any asynchronous decoder instantiation settle. - await new Promise((resolve) => setTimeout(resolve, 100)) - for (const { sixel, iip } of panes) { - expect(sixel._dec).toBeUndefined() - expect(iip._dec._inst).toBeNull() - expect(iip._qoiDec._inst).toBeFalsy() - } - } finally { - for (const { terminal } of panes) { - terminal.dispose() - } - } - }) - - it('returns decoders after each SIXEL and IIP image', async () => { - const painted = stubCanvasGlobals() - const { terminal, addon, sixel, iip } = createTerminal() - let added = 0 - addon.onImageAdded(() => added++) - try { - await write(terminal, SIXEL_RED_REGISTER_1) - expect(painted).toHaveLength(1) - expect(sixel._dec).toBeUndefined() - - await write(terminal, IIP_PNG) - await new Promise((resolve) => setTimeout(resolve, 0)) - expect(iip._dec._inst).toBeNull() - expect(added).toBe(2) - } finally { - terminal.dispose() - } - }) - it('keeps SIXEL color registers across images until a terminal reset', async () => { const painted = stubCanvasGlobals() const { terminal } = createTerminal() diff --git a/config/scripts/terminal-dependencies/xterm-patches/xterm-underline-color-contract.test.mjs b/config/scripts/terminal-dependencies/xterm-patches/xterm-underline-color-contract.test.mjs deleted file mode 100644 index c021a2e4270..00000000000 --- a/config/scripts/terminal-dependencies/xterm-patches/xterm-underline-color-contract.test.mjs +++ /dev/null @@ -1,29 +0,0 @@ -import { createRequire } from 'node:module' -import { expect, it } from 'vitest' - -const require = createRequire( - new URL('../../xterm-underline-color-contract.test.mjs', import.meta.url) -) -const { Terminal } = require('@xterm/xterm') - -function write(terminal, text) { - return new Promise((resolve) => terminal.write(text, resolve)) -} - -it('retains underline color without drawing an underline, including explicit white and reset', async () => { - const terminal = new Terminal({ allowProposedApi: true }) - try { - await write(terminal, '\x1b[58;2;0;0;10mA\x1b[58;2;255;255;255mB\x1b[59mC') - const line = terminal._core.buffer.lines.get(0) - expect(line._extendedAttrs[0].underlineColor & 0xffffff).toBe(10) - expect(line._extendedAttrs[0].underlineStyle).toBe(0) - expect(line._extendedAttrs[1].underlineColor & 0xffffff).toBe(0xffffff) - expect(line._extendedAttrs[1].underlineStyle).toBe(0) - expect(line._extendedAttrs[2]).toBeUndefined() - await write(terminal, '\x1b[4mD') - expect(line._extendedAttrs[3].underlineStyle).toBe(1) - expect(line._extendedAttrs[3].underlineColor).toBe(0) - } finally { - terminal.dispose() - } -}) diff --git a/config/scripts/test-runtime/execution-policy/vitest-run-filters.test.mjs b/config/scripts/test-runtime/execution-policy/vitest-run-filters.test.mjs deleted file mode 100644 index 8d0aa6476ca..00000000000 --- a/config/scripts/test-runtime/execution-policy/vitest-run-filters.test.mjs +++ /dev/null @@ -1,53 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { parseRunFilters, readRunFilters, RUN_ARGS_ENV } from './vitest-run-filters.mjs' -import { matchesRunFilter } from '../sqlite-admission/vitest-sqlite-runtime-scan.mjs' - -describe('parseRunFilters', () => { - it('returns the positional filters of a one-shot run', () => { - expect( - parseRunFilters([ - 'run', - '--config', - 'config/vitest.config.ts', - 'src/main/runtime', - '--maxWorkers=2', - '-t', - 'name', - 'src/shared/a.test.ts:12' - ]) - ).toEqual(['src/main/runtime', 'src/shared/a.test.ts:12']) - }) - - it('treats an unknown option value as a filter, widening rather than narrowing the scan', () => { - expect(parseRunFilters(['run', '--changed', 'src/a', '--unknown', '7'])).toEqual(['src/a', '7']) - }) - - it.each([ - [['run', '--config', 'x']], - [['watch', 'src/a']], - [['related', 'src/a.ts']], - [['run', '--watch', 'src/a']], - [['run', '--dir', 'src', 'a']], - [['run', 'src/a', '--', 'b']] - ])('scans every file for %j', (args) => { - expect(parseRunFilters(args)).toBeUndefined() - }) - - it('ignores inherited arguments that this process was not launched with', () => { - const args = ['run', 'src/a'] - const env = { [RUN_ARGS_ENV]: JSON.stringify(args) } - expect(readRunFilters(env, ['bun', 'vitest.mjs', ...args])).toEqual(['src/a']) - expect(readRunFilters(env, ['bun', 'vitest.mjs', 'run', 'src/b'])).toBeUndefined() - }) -}) - -describe('matchesRunFilter', () => { - it('matches every file a Vitest substring or line filter selects', () => { - const file = 'src/shared/worktree/Branch-Name.test.ts' - expect(matchesRunFilter(file, ['src/shared/worktree'])).toBe(true) - expect(matchesRunFilter(file, ['branch-name'])).toBe(true) - expect(matchesRunFilter(file, [`${file}:12`])).toBe(true) - expect(matchesRunFilter(file, [`${process.cwd()}/src/shared/`])).toBe(true) - expect(matchesRunFilter(file, ['src/main'])).toBe(false) - }) -}) diff --git a/config/scripts/test-runtime/node-worker/vitest-node-runtime-boundary.test.ts b/config/scripts/test-runtime/node-worker/vitest-node-runtime-boundary.test.ts deleted file mode 100644 index 725c0909011..00000000000 --- a/config/scripts/test-runtime/node-worker/vitest-node-runtime-boundary.test.ts +++ /dev/null @@ -1,60 +0,0 @@ -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([]) -}) diff --git a/config/scripts/test-runtime/sqlite-admission/vitest-node-runtime-files.mjs b/config/scripts/test-runtime/sqlite-admission/vitest-node-runtime-files.mjs index a4d39391e22..db5b227e0c5 100644 --- a/config/scripts/test-runtime/sqlite-admission/vitest-node-runtime-files.mjs +++ b/config/scripts/test-runtime/sqlite-admission/vitest-node-runtime-files.mjs @@ -205,7 +205,6 @@ const NODE_RUNTIME_INCLUDE = [ 'src/main/claude/claude-agent-sdk-contract-pins.test.ts', 'config/scripts/orcad-distribution/server-bundle/profile-state-worker-smoke.test.mjs', 'config/scripts/desktop-distribution/runtime-verification/process-host-dev-rebuild.test.ts', - 'config/scripts/test-runtime/node-worker/vitest-node-runtime-boundary.test.ts', 'config/scripts/test-runtime/node-worker/vitest-node-runtime-pool.test.ts' ] diff --git a/config/scripts/tool-invocation/oxc-cli-invocation.test.mjs b/config/scripts/tool-invocation/oxc-cli-invocation.test.mjs deleted file mode 100644 index aebff7e2b4b..00000000000 --- a/config/scripts/tool-invocation/oxc-cli-invocation.test.mjs +++ /dev/null @@ -1,39 +0,0 @@ -import { spawnSync } from 'node:child_process' -import { existsSync } from 'node:fs' -import path from 'node:path' -import process from 'node:process' -import { describe, expect, it } from 'vitest' -import { resolveOxcCliInvocation } from './oxc-cli-invocation.mjs' -import { resolveOxlintInvocation } from './oxlint-cli-invocation.mjs' - -const repoRoot = path.resolve(import.meta.dirname, '../..', '..') - -for (const { name, resolveInvocation } of [ - { name: 'oxfmt', resolveInvocation: () => resolveOxcCliInvocation('oxfmt', 'oxfmt', repoRoot) }, - { name: 'oxlint', resolveInvocation: () => resolveOxlintInvocation(repoRoot) } -]) { - describe(`${name} CLI invocation`, () => { - it('launches the installed CLI without a shell', () => { - const { command, prefixArgs } = resolveInvocation() - expect(command).toBe(process.execPath) - expect(prefixArgs).toHaveLength(1) - expect(prefixArgs[0]).not.toMatch(/\.(cmd|bat)$/i) - expect(existsSync(prefixArgs[0])).toBe(true) - const result = spawnSync(command, [...prefixArgs, '--help'], { - cwd: repoRoot, - encoding: 'utf8', - shell: false, - windowsHide: true - }) - expect(result.error).toBeUndefined() - expect(result.status).toBe(0) - expect(result.stdout).toContain(name) - }) - }) -} - -it('names the package and bin it could not find', () => { - expect(() => resolveOxcCliInvocation('oxfmt', 'nope', repoRoot)).toThrow( - 'oxfmt package.json declares no "nope" bin entry.' - ) -}) diff --git a/config/scripts/typecheck/e2e-admission/run-e2e-typecheck.test.mjs b/config/scripts/typecheck/e2e-admission/run-e2e-typecheck.test.mjs deleted file mode 100644 index 5a176a9ff29..00000000000 --- a/config/scripts/typecheck/e2e-admission/run-e2e-typecheck.test.mjs +++ /dev/null @@ -1,119 +0,0 @@ -import { mkdirSync, mkdtempSync, rmSync, symlinkSync, writeFileSync } from 'node:fs' -import { availableParallelism, tmpdir } from 'node:os' -import { join, resolve } from 'node:path' -import { runProcessSync } from '@orca/process-host' -import { afterEach, expect, it, vi } from 'vitest' -import { countTestTypeErrors } from './check-e2e-typecheck-ratchet.mjs' -import { resolvePinnedBunExecutable } from '../../tool-invocation/pinned-bun-executable.mjs' -import { runE2eTypecheck } from './run-e2e-typecheck.mjs' - -const ROOT = process.cwd() -const resolveBunExecutable = () => resolvePinnedBunExecutable(ROOT, runProcessSync) -const directories = [] -const diagnostic = 'tests/entry.ts(1,1): error TS2322: Type error.\n' - -afterEach(() => { - for (const directory of directories.splice(0)) { - rmSync(directory, { recursive: true, force: true }) - } -}) - -function fixture() { - const root = mkdtempSync(join(tmpdir(), 'orca-e2e-check-')) - directories.push(root) - mkdirSync(join(root, 'config')) - mkdirSync(join(root, 'tests')) - symlinkSync(resolve('node_modules'), join(root, 'node_modules'), 'junction') - writeFileSync(join(root, 'package.json'), '{"type":"commonjs"}') - writeFileSync( - join(root, 'config', 'tsconfig.e2e.json'), - JSON.stringify({ - compilerOptions: { - module: 'Node20', - moduleResolution: 'Node16', - target: 'ES2022', - strict: true, - types: [] - }, - include: ['../tests/**/*.ts'] - }) - ) - writeFileSync(join(root, 'tests', 'exports.ts'), 'export const value = 1\n') - writeFileSync( - join(root, 'tests', 'entry.ts'), - "import { missing } from './exports'\nexport const value: number = 'wrong'\n" - ) - return root -} - -it('captures all diagnostics using the pinned Bun and all available CPU cores', () => { - const execute = vi.fn(() => ({ code: 1, stdout: diagnostic, stderr: 'summary' })) - expect(runE2eTypecheck({ execute, resolveBunExecutable: () => 'pinned-bun' })).toEqual({ - code: 1, - output: `${diagnostic}summary` - }) - expect(execute).toHaveBeenCalledWith({ - program: 'pinned-bun', - args: [ - 'check', - '-p', - 'config/tsconfig.e2e.json', - '--threads', - String(availableParallelism()), - '--no-pretty', - '--all' - ], - cwd: ROOT, - timeoutMs: null, - maxOutputBytes: 64 * 1024 * 1024 - }) -}) - -it.each([ - { code: 1, stdout: '', stderr: 'failed to start' }, - { code: null, stdout: diagnostic, signal: 'SIGKILL' }, - { code: 0, stdout: diagnostic, timedOut: true }, - { code: 1, stdout: diagnostic, outputTruncated: true }, - { code: 99, stdout: diagnostic }, - { code: null, stdout: diagnostic } -])('rejects failed or incomplete checks before the ratchet can prune errors: %j', (result) => { - expect(() => - runE2eTypecheck({ - execute: () => result, - resolveBunExecutable: () => 'pinned-bun' - }) - ).toThrow('failed to run') -}) - -it('does not run when Bun is missing or the project compiler version has drifted', () => { - const execute = vi.fn() - expect(() => runE2eTypecheck({ execute, resolveBunExecutable: () => null })).toThrow('missing') - const root = fixture() - mkdirSync(join(root, 'config', 'node_modules', 'typescript'), { recursive: true }) - writeFileSync( - join(root, 'config', 'node_modules', 'typescript', 'package.json'), - JSON.stringify({ version: '0.0.0', bin: { tsc: './bin/tsc' } }) - ) - expect(() => - runE2eTypecheck({ - root, - execute, - resolveBunExecutable: () => 'pinned-bun' - }) - ).toThrow('resolves 0.0.0') - expect(execute).not.toHaveBeenCalled() -}) - -it('keeps real missing-export and type-error diagnostics identical to TypeScript', () => { - const root = fixture() - const native = runE2eTypecheck({ root, compiler: 'native' }) - const bun = runE2eTypecheck({ root, resolveBunExecutable }) - const locations = (output) => - [...output.matchAll(/^.+\(\d+,\d+\): error TS\d+:/gm)].map(([line]) => line).sort() - expect(locations(bun.output)).toEqual(locations(native.output)) - expect(locations(bun.output)).toHaveLength(2) - expect(countTestTypeErrors(bun.output)).toEqual(new Map([['tests/entry.ts', 2]])) - writeFileSync(join(root, 'tests', 'entry.ts'), "export { value } from './exports'\n") - expect(runE2eTypecheck({ root, resolveBunExecutable }).code).toBe(0) - expect(runE2eTypecheck({ root, compiler: 'native' }).code).toBe(0) -}) diff --git a/config/scripts/typecheck/language-server/agent-typescript-lsp.test.mjs b/config/scripts/typecheck/language-server/agent-typescript-lsp.test.mjs deleted file mode 100644 index 0107d6c3eda..00000000000 --- a/config/scripts/typecheck/language-server/agent-typescript-lsp.test.mjs +++ /dev/null @@ -1,137 +0,0 @@ -import { existsSync, readFileSync } from 'node:fs' -import { join } from 'node:path' -import { fileURLToPath } from 'node:url' -import { describe, expect, it } from 'vitest' -import { - createDiagnosticsBridge, - createLspMessageReader, - encodeLspMessage -} from './agent-typescript-lsp.mjs' - -const repoRoot = fileURLToPath(new URL('../../../..', import.meta.url)) -const uri = 'file:///repo/src/a.ts' - -function harness(clientCapabilities) { - const client = [] - const server = [] - const timers = new Map() - let nextTimer = 0 - const bridge = createDiagnosticsBridge({ - toClient: (message) => client.push(message), - toServer: (message) => server.push(message), - setTimer: (run) => { - timers.set(++nextTimer, run) - return nextTimer - }, - clearTimer: (id) => timers.delete(id) - }) - bridge.fromClient({ - jsonrpc: '2.0', - id: 0, - method: 'initialize', - params: { capabilities: clientCapabilities } - }) - const flush = () => { - const pending = [...timers.values()] - timers.clear() - pending.forEach((run) => run()) - } - const pulls = () => server.filter((message) => message.method === 'textDocument/diagnostic') - const pushes = () => - client.filter((message) => message.method === 'textDocument/publishDiagnostics') - return { bridge, client, server, flush, pulls, pushes } -} - -const edit = (version) => ({ - jsonrpc: '2.0', - method: 'textDocument/didChange', - params: { textDocument: { uri, version }, contentChanges: [{ text: `v${version}` }] } -}) -const report = (id, message) => ({ - jsonrpc: '2.0', - id, - result: { kind: 'full', items: [{ message }] } -}) - -describe('agent TypeScript LSP diagnostics bridge', () => { - it('pushes pulled diagnostics to a push-only client and drops results an edit outdated', () => { - const { bridge, server, flush, pulls, pushes } = harness({ textDocument: {} }) - expect(server[0].params.capabilities.textDocument.diagnostic).toBeDefined() - - bridge.fromClient({ - jsonrpc: '2.0', - method: 'textDocument/didOpen', - params: { textDocument: { uri, version: 1, languageId: 'typescript', text: 'v1' } } - }) - bridge.fromClient(edit(2)) - flush() - expect(pulls()).toHaveLength(1) - const outdated = pulls()[0].id - - bridge.fromClient(edit(3)) - bridge.fromServer(report(outdated, 'stale')) - expect(pushes()).toEqual([]) - - flush() - bridge.fromServer(report(pulls()[1].id, 'fresh')) - expect(pushes()).toEqual([ - { - jsonrpc: '2.0', - method: 'textDocument/publishDiagnostics', - params: { uri, version: 3, diagnostics: [{ message: 'fresh' }] } - } - ]) - }) - - it('re-pulls open documents when the server asks for a refresh', () => { - const { bridge, client, server, flush, pulls } = harness({}) - bridge.fromClient({ - jsonrpc: '2.0', - method: 'textDocument/didOpen', - params: { textDocument: { uri, version: 1, languageId: 'typescript', text: 'v1' } } - }) - flush() - bridge.fromServer({ jsonrpc: '2.0', id: 'srv-1', method: 'workspace/diagnostic/refresh' }) - flush() - expect(pulls()).toHaveLength(2) - expect(server).toContainEqual({ jsonrpc: '2.0', id: 'srv-1', result: null }) - expect(client.some((message) => message.method === 'workspace/diagnostic/refresh')).toBe(false) - }) - - it('stays out of the way of a client that pulls diagnostics itself', () => { - const capabilities = { textDocument: { diagnostic: {} } } - const { bridge, client, server, flush, pulls } = harness(capabilities) - expect(server[0].params.capabilities).toBe(capabilities) - bridge.fromClient(edit(1)) - flush() - expect(pulls()).toEqual([]) - bridge.fromServer({ jsonrpc: '2.0', id: 'srv-1', method: 'workspace/diagnostic/refresh' }) - expect(client.at(-1).method).toBe('workspace/diagnostic/refresh') - }) - - it('reassembles messages split across and packed into stdio chunks', () => { - const received = [] - const read = createLspMessageReader((message) => received.push(message)) - const frames = Buffer.concat([ - encodeLspMessage({ id: 1, text: 'héllo' }), - encodeLspMessage({ id: 2 }) - ]) - read(frames.subarray(0, 7)) - const split = frames.indexOf(Buffer.from('é')) + 1 - read(frames.subarray(7, split)) - read(frames.subarray(split)) - expect(received).toEqual([{ id: 1, text: 'héllo' }, { id: 2 }]) - }) - - it('wires Claude and OpenCode to the repository language server', () => { - const plugin = JSON.parse( - readFileSync(join(repoRoot, 'config/agent-plugins/orca-typescript/.lsp.json'), 'utf8') - ) - const opencode = JSON.parse(readFileSync(join(repoRoot, 'opencode.json'), 'utf8')) - const script = 'config/scripts/typecheck/language-server/agent-typescript-lsp.mjs' - expect(existsSync(join(repoRoot, script))).toBe(true) - expect(plugin['orca-typescript'].command).toBe('node') - expect(plugin['orca-typescript'].args).toEqual([`\${CLAUDE_PROJECT_DIR}/${script}`]) - expect(opencode.lsp['orca-typescript'].command).toEqual(['node', script]) - }) -}) diff --git a/config/scripts/typecheck/project-execution/run-typecheck-projects-in-parallel.test.mjs b/config/scripts/typecheck/project-execution/run-typecheck-projects-in-parallel.test.mjs index 5c018b793e0..c0c9252e5d9 100644 --- a/config/scripts/typecheck/project-execution/run-typecheck-projects-in-parallel.test.mjs +++ b/config/scripts/typecheck/project-execution/run-typecheck-projects-in-parallel.test.mjs @@ -1,335 +1,10 @@ -import { - existsSync, - readFileSync, - mkdirSync, - mkdtempSync, - readdirSync, - realpathSync, - rmSync, - writeFileSync -} from 'node:fs' +import { readFileSync, mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from 'node:fs' import { tmpdir } from 'node:os' -import { join, relative, sep } from 'node:path' -import { fileURLToPath } from 'node:url' +import { join } from 'node:path' import { describe, expect, it } from 'vitest' -import { resolvePinnedBunExecutable } from '../../tool-invocation/pinned-bun-executable.mjs' -import { - MOBILE_TYPECHECK_PROJECTS, - TYPECHECK_PROJECTS, - admissibleHeapGib, - planTypecheckBatches, - resolveProjectCompiler, - resolveTypecheckBunExecutable, - resolveTypecheckCommand, - parseTypecheckOptions, - selectTypecheckCompiler, - typecheckBatches, - runTypecheckProjects -} from './run-typecheck-projects-in-parallel.mjs' - -const repoRoot = fileURLToPath(new URL('../../../..', import.meta.url)) - -const CI_RUNNER = { totalBytes: 16 * 1024 ** 3, parallelism: 4 } -const DEV_LAPTOP = { totalBytes: 64 * 1024 ** 3, parallelism: 18 } - -function planFor({ totalBytes, parallelism }, projects = TYPECHECK_PROJECTS) { - return planTypecheckBatches(projects, { - budgetGib: admissibleHeapGib(totalBytes), - parallelism - }) -} - -function batchOf(batches, config) { - return batches.findIndex((batch) => batch.some((project) => project.config === config)) -} - -describe('typecheck project admission', () => { - it('keeps the two expensive projects off the same CI runner', () => { - const batches = planFor(CI_RUNNER) - expect(batchOf(batches, 'config/tsconfig.node.json')).not.toBe( - batchOf(batches, 'config/tsconfig.tc.web.json') - ) - }) - - it('holds every CI batch inside the memory budget', () => { - const budget = admissibleHeapGib(CI_RUNNER.totalBytes) - for (const batch of planFor(CI_RUNNER)) { - const claimed = batch.reduce((total, project) => total + project.heapGib, 0) - expect(claimed).toBeLessThanOrEqual(budget) - } - }) - - it('still fills a CI batch with the cheap projects rather than serializing everything', () => { - // Why: strict serialization measured ~60% slower than pairing the cheap work alongside. - expect(planFor(CI_RUNNER).length).toBeLessThan(TYPECHECK_PROJECTS.length) - }) - - it('leaves a roomy machine fully parallel', () => { - expect(planFor(DEV_LAPTOP)).toHaveLength(1) - }) - - it('serializes on a single core', () => { - const batches = planFor({ totalBytes: 64 * 1024 ** 3, parallelism: 1 }) - expect(batches).toHaveLength(TYPECHECK_PROJECTS.length) - expect(batches.every((batch) => batch.length === 1)).toBe(true) - }) - - it('runs a project that alone exceeds the budget instead of stalling', () => { - const batches = planTypecheckBatches([{ config: 'huge.json', heapGib: 512 }], { - budgetGib: admissibleHeapGib(2 * 1024 ** 3), - parallelism: 4 - }) - expect(batches).toEqual([[{ config: 'huge.json', heapGib: 512 }]]) - }) - - it('schedules every project exactly once', () => { - const scheduled = planFor(CI_RUNNER) - .flat() - .map((project) => project.config) - .sort() - expect(scheduled).toEqual(TYPECHECK_PROJECTS.map((project) => project.config).sort()) - }) - - it('never lets one project outgrow a CI runner on its own', () => { - // A single project over budget runs anyway, so this is the ceiling the pool cannot rescue. - const heaviest = Math.max(...TYPECHECK_PROJECTS.map((project) => project.heapGib)) - expect(heaviest).toBeLessThanOrEqual(admissibleHeapGib(CI_RUNNER.totalBytes)) - }) -}) - -describe('workspace package test typecheck', () => { - const packagesDir = join(repoRoot, 'src', 'packages') - const packageTestProjects = readdirSync(packagesDir) - .map((name) => join(packagesDir, name, 'tsconfig.test.json')) - .filter((config) => existsSync(config)) - .map((config) => relative(repoRoot, config).split(sep).join('/')) - - it('type-checks every package test project, which no root project includes', () => { - expect(packageTestProjects).toContain('src/packages/process-host/tsconfig.test.json') - const scheduled = TYPECHECK_PROJECTS.map((project) => project.config) - expect(scheduled).toEqual(expect.arrayContaining(packageTestProjects)) - }) - - it("resolves a package project's compiler from that package, not the root", () => { - const root = realpathSync(mkdtempSync(join(tmpdir(), 'orca-typecheck-compiler-'))) - try { - const writeCompiler = (directory, version) => { - const compilerDir = join(root, directory, 'node_modules', 'typescript') - mkdirSync(join(compilerDir, 'bin'), { recursive: true }) - writeFileSync( - join(compilerDir, 'package.json'), - JSON.stringify({ name: 'typescript', version, bin: { tsc: './bin/tsc' } }) - ) - return join(compilerDir, 'bin', 'tsc') - } - const rootCompiler = writeCompiler('.', '6.0.0') - const packageCompiler = writeCompiler('src/packages/example', '7.0.0') - mkdirSync(join(root, 'config')) - - expect(resolveProjectCompiler('src/packages/example/tsconfig.test.json', root)).toBe( - packageCompiler - ) - expect(resolveProjectCompiler('config/tsconfig.node.json', root)).toBe(rootCompiler) - } finally { - rmSync(root, { recursive: true, force: true }) - } - }) -}) +import { runTypecheckProjects } from './run-typecheck-projects-in-parallel.mjs' describe('local and CI compiler selection', () => { - it('defaults to automatic compiler selection while CI explicitly selects Bun', () => { - expect(parseTypecheckOptions([]).compiler).toBe('auto') - const manifest = JSON.parse(readFileSync(join(repoRoot, 'package.json'), 'utf8')) - expect(manifest.scripts['typecheck:ci']).toContain('--compiler=bun') - }) - - it.each([ - ['darwin', 'arm64', 'tsrs'], - ['linux', 'x64', 'tsrs'], - ['linux', 'arm64', 'tsrs'], - ['darwin', 'x64', 'bun'], - ['win32', 'x64', 'bun'], - ['win32', 'arm64', 'bun'] - ])('selects %s/%s without probing an unsupported binary', (platform, arch, compiler) => { - const selection = selectTypecheckCompiler('auto', { - root: repoRoot, - platform, - arch, - resolveBunExecutable: () => { - if (compiler !== 'bun') { - throw new Error('unexpected Bun probe') - } - return 'pinned-bun' - } - }) - expect(selection.compiler).toBe(compiler) - }) - - it('rejects explicitly requested tsrs on an unsupported platform', () => { - expect(() => selectTypecheckCompiler('tsrs', { platform: 'win32', arch: 'x64' })).toThrow( - 'use --compiler=bun' - ) - expect(parseTypecheckOptions(['--compiler=tsrs']).compiler).toBe('tsrs') - }) - - it('bounds local tsrs concurrency and respects memory admission', () => { - for (const memoryBytes of [4, 16, 128].map((gib) => gib * 1024 ** 3)) { - const batches = typecheckBatches(TYPECHECK_PROJECTS, { - compiler: 'tsrs', - memoryBytes, - parallelism: 16 - }) - expect(Math.max(...batches.map((batch) => batch.length))).toBeLessThanOrEqual(2) - if (memoryBytes === 4 * 1024 ** 3) { - expect(batches.every((batch) => batch.length === 1)).toBe(true) - } - } - }) - - it('pins the Bun devDependency to config/.bun-version', () => { - const manifest = JSON.parse(readFileSync(join(repoRoot, 'package.json'), 'utf8')) - expect(manifest.devDependencies.bun).toBe( - readFileSync(join(repoRoot, 'config', '.bun-version'), 'utf8').trim() - ) - }) - - it('narrows to the requested projects and rejects unknown ones', () => { - expect(parseTypecheckOptions(['--project=config/tsconfig.node.json']).projects).toEqual([ - TYPECHECK_PROJECTS[0] - ]) - expect(parseTypecheckOptions([]).projects).toEqual(TYPECHECK_PROJECTS) - expect(parseTypecheckOptions(['--project=mobile/tsconfig.test.json']).projects).toEqual([ - MOBILE_TYPECHECK_PROJECTS[1] - ]) - expect(TYPECHECK_PROJECTS).not.toContainEqual(MOBILE_TYPECHECK_PROJECTS[0]) - expect(() => parseTypecheckOptions(['--project=config/tsconfig.json'])).toThrow() - }) - - it('selects the resolved Bun path and rejects a missing executable', () => { - expect( - selectTypecheckCompiler('bun', { - root: repoRoot, - resolveBunExecutable: () => '/repo/node_modules/bun/bin/bun.exe' - }) - ).toEqual({ compiler: 'bun', bunExecutable: '/repo/node_modules/bun/bin/bun.exe' }) - expect(() => - selectTypecheckCompiler('bun', { root: repoRoot, resolveBunExecutable: () => null }) - ).toThrow('run pnpm install') - }) - - it('reports a timed-out installed Bun probe without changing optional fallback', () => { - const root = realpathSync(mkdtempSync(join(tmpdir(), 'orca-bun-probe-'))) - try { - const manifest = join(root, 'node_modules', 'bun') - mkdirSync(manifest, { recursive: true }) - mkdirSync(join(root, 'config')) - writeFileSync(join(root, 'package.json'), '{}') - writeFileSync(join(root, 'config', '.bun-version'), '1.4.4') - writeFileSync(join(manifest, 'package.json'), JSON.stringify({ bin: { bun: 'bin/bun' } })) - const execute = () => ({ code: null, signal: 'SIGTERM', stdout: '', timedOut: true }) - expect(resolvePinnedBunExecutable(root, execute)).toBeNull() - expect(() => - selectTypecheckCompiler('bun', { - root, - resolveBunExecutable: (directory, hint) => - resolveTypecheckBunExecutable(directory, hint, execute) - }) - ).toThrow(/Bun version probe timed out after 2000 ms: .*or pass --compiler=native\./) - expect(() => resolveTypecheckBunExecutable(root, null, execute)).toThrow( - /Retry when the host is less busy\.$/ - ) - expect( - resolveTypecheckBunExecutable(root, null, () => ({ code: 0, stdout: '1.4.4\n' })) - ).toBe(join(manifest, 'bin/bun')) - expect( - resolveTypecheckBunExecutable(root, null, () => ({ code: 0, stdout: '1.4.3\n' })) - ).toBeNull() - } finally { - rmSync(root, { recursive: true, force: true }) - } - }) - - it('never probes Bun when tsc is requested', () => { - expect( - selectTypecheckCompiler('native', { - root: repoRoot, - resolveBunExecutable: () => { - throw new Error('probed') - } - }) - ).toEqual({ compiler: 'native' }) - }) - - it.each([ - '--compiler=typo', - '--bun-concurrency=0', - '--bun-threads=NaN', - '--bun-concurrency=5', - '--checkers=0', - '--checkers=two', - '--project' - ])('rejects unsafe or unknown options: %s', (argument) => { - expect(() => parseTypecheckOptions([argument])).toThrow() - }) - - it('passes a checker cap to the native compiler only when one is requested', () => { - const command = (checkers) => - resolveTypecheckCommand('config/tsconfig.node.json', { - compiler: 'native', - checkers, - root: repoRoot - }).args - expect(command(parseTypecheckOptions(['--checkers=4']).checkers).slice(-2)).toEqual([ - '--checkers', - '4' - ]) - expect(command(parseTypecheckOptions([]).checkers)).not.toContain('--checkers') - }) - - it('bounds Bun project concurrency and reserves memory for overlapping checks', () => { - const options = parseTypecheckOptions([ - '--compiler=bun', - '--bun-concurrency=2', - '--bun-threads=2' - ]) - const batches = typecheckBatches(TYPECHECK_PROJECTS, { - ...options, - memoryBytes: CI_RUNNER.totalBytes, - parallelism: 4 - }) - expect(batches.map((batch) => batch.length)).toEqual([2, 2, 1]) - expect(batches.flat().map((project) => project.config)).toEqual( - TYPECHECK_PROJECTS.map((project) => project.config) - ) - expect( - typecheckBatches(TYPECHECK_PROJECTS, { - ...options, - memoryBytes: 4 * 1024 ** 3, - parallelism: 4 - }).every((batch) => batch.length === 1) - ).toBe(true) - }) - - it('rejects a mismatched package compiler before invoking Bun', async () => { - const root = realpathSync(mkdtempSync(join(tmpdir(), 'orca-bun-compiler-version-'))) - try { - mkdirSync(join(root, 'node_modules', 'typescript'), { recursive: true }) - writeFileSync( - join(root, 'node_modules', 'typescript', 'package.json'), - JSON.stringify({ name: 'typescript', version: '8.0.0', bin: 'compiler.cjs' }) - ) - const failures = await runTypecheckProjects({ - compiler: 'bun', - root, - projects: [{ config: 'tsconfig.json', heapGib: 1 }] - }) - expect(failures).toHaveLength(1) - expect(failures[0].message).toContain('resolves 8.0.0') - } finally { - rmSync(root, { recursive: true, force: true }) - } - }) - it('continues to later projects after a compiler exits with an error', async () => { const root = realpathSync(mkdtempSync(join(tmpdir(), 'orca-typecheck-failure-'))) try { diff --git a/config/scripts/typecheck/project-execution/tsrs-typecheck-compiler.test.mjs b/config/scripts/typecheck/project-execution/tsrs-typecheck-compiler.test.mjs deleted file mode 100644 index 1141e069961..00000000000 --- a/config/scripts/typecheck/project-execution/tsrs-typecheck-compiler.test.mjs +++ /dev/null @@ -1,137 +0,0 @@ -import { - existsSync, - mkdirSync, - mkdtempSync, - readFileSync, - rmSync, - symlinkSync, - writeFileSync -} from 'node:fs' -import { tmpdir } from 'node:os' -import { dirname, join, resolve } from 'node:path' -import { pathToFileURL } from 'node:url' -import { runProcessSync } from '@orca/process-host' -import { expect, it } from 'vitest' -import { resolveTsrsTypecheckCommand, supportsTsrs } from './tsrs-typecheck-compiler.mjs' - -it('isolates cache files by project, worktree and compiler version', () => { - const root = mkdtempSync(join(tmpdir(), 'orca-tsrs-paths-')) - try { - const manifest = join(root, 'node_modules', 'tsrs', 'package.json') - mkdirSync(dirname(manifest), { recursive: true }) - const install = (version) => - writeFileSync(manifest, JSON.stringify({ version, bin: { tsrs: 'bin/tsrs' } })) - install('0.18.0') - const cache = (config, directory = root) => { - const command = resolveTsrsTypecheckCommand(config, directory) - return command.args[command.args.indexOf('--tsBuildInfoFile') + 1] - } - const first = cache('a/tsconfig.json') - expect(cache('a/tsconfig.json')).toBe(first) - expect(cache('b/tsconfig.json')).not.toBe(first) - install('0.19.0') - expect(cache('a/tsconfig.json')).not.toBe(first) - const other = join(root, 'other-worktree') - mkdirSync(other) - symlinkSync(join(root, 'node_modules'), join(other, 'node_modules'), 'junction') - expect(cache('a/tsconfig.json', other)).not.toBe(cache('a/tsconfig.json')) - expect(existsSync(dirname(first))).toBe(true) - } finally { - rmSync(root, { recursive: true, force: true }) - } -}) - -it('explains how to install a missing local compiler', () => { - const root = mkdtempSync(join(tmpdir(), 'orca-tsrs-missing-')) - try { - const module = pathToFileURL( - resolve('config/scripts/typecheck/project-execution/tsrs-typecheck-compiler.mjs') - ).href - const result = runProcessSync({ - program: process.env.ORCA_TEST_NODE_EXECUTABLE ?? process.execPath, - args: [ - '--input-type=module', - '-e', - `import { resolveTsrsTypecheckCommand } from ${JSON.stringify(module)}; resolveTsrsTypecheckCommand('tsconfig.json', process.argv[1])`, - root - ], - cwd: root, - timeoutMs: 10_000 - }) - expect(result.code).not.toBe(0) - expect(result.stderr).toContain('run pnpm install') - } finally { - rmSync(root, { recursive: true, force: true }) - } -}) - -it.skipIf(!supportsTsrs())( - 'reuses a real cache and invalidates exported types, deleted files and config changes', - () => { - const root = mkdtempSync(join(tmpdir(), 'orca-tsrs-incremental-')) - try { - symlinkSync(resolve('node_modules'), join(root, 'node_modules'), 'junction') - writeFileSync(join(root, 'package.json'), '{"type":"commonjs"}') - const config = join(root, 'tsconfig.json') - const writeConfig = (strictNullChecks) => - writeFileSync( - config, - JSON.stringify({ - compilerOptions: { - target: 'ES2022', - module: 'Node16', - moduleResolution: 'Node16', - strict: true, - strictNullChecks, - skipLibCheck: true, - types: [] - }, - include: ['*.ts'] - }) - ) - writeConfig(true) - const model = join(root, 'model.ts') - writeFileSync(model, 'export interface Model { value: number }\n') - writeFileSync( - join(root, 'consumer.ts'), - "import type { Model } from './model'\nexport const model: Model = { value: 1 }\n" - ) - const command = resolveTsrsTypecheckCommand('tsconfig.json', root) - const check = () => - runProcessSync({ - ...command, - args: [...command.args, '--pretty', 'false'], - timeoutMs: 30_000, - env: { ...process.env, ORCA_BACKGROUND_LAUNCH: '1' } - }) - expect(check().code).toBe(0) - const cache = command.args[command.args.indexOf('--tsBuildInfoFile') + 1] - expect(existsSync(cache)).toBe(true) - const saved = readFileSync(cache, 'utf8') - expect(check().code).toBe(0) - expect(readFileSync(cache, 'utf8')).toBe(saved) - - writeFileSync(model, 'export interface Model { value: string }\n') - const broken = check() - expect(broken.code).not.toBe(0) - expect(broken.stdout + broken.stderr).toContain('TS2322') - writeFileSync(model, 'export interface Model { value: number }\n') - expect(check().code).toBe(0) - - writeFileSync(join(root, 'deleted.ts'), 'export const invalid: number = "reject"\n') - expect(check().code).not.toBe(0) - rmSync(join(root, 'deleted.ts')) - expect(check().code).toBe(0) - - writeFileSync(join(root, 'nullable.ts'), 'export const nullable: string = null\n') - expect(check().code).not.toBe(0) - writeConfig(false) - expect(check().code).toBe(0) - writeConfig(true) - expect(check().code).not.toBe(0) - } finally { - rmSync(root, { recursive: true, force: true }) - } - }, - 60_000 -) diff --git a/config/scripts/typecheck/project-execution/typecheck-project-coverage.test.mjs b/config/scripts/typecheck/project-execution/typecheck-project-coverage.test.mjs deleted file mode 100644 index ba23a4fd43e..00000000000 --- a/config/scripts/typecheck/project-execution/typecheck-project-coverage.test.mjs +++ /dev/null @@ -1,72 +0,0 @@ -import { globSync } from 'node:fs' -import { resolve } from 'node:path' -import { fileURLToPath } from 'node:url' -import ts from 'typescript-api' -import { describe, expect, it } from 'vitest' -import { TYPECHECK_PROJECTS } from './run-typecheck-projects-in-parallel.mjs' - -const root = fileURLToPath(new URL('../../../..', import.meta.url)) -const isTest = (file) => /\.(?:test|spec)\.(?:[cm]?ts|tsx)$/.test(file) -const projects = TYPECHECK_PROJECTS.filter((project) => project.config.startsWith('config/')).map( - ({ config }) => { - const parsed = ts.getParsedCommandLineOfConfigFile(resolve(root, config), undefined, { - ...ts.sys, - onUnRecoverableConfigFileDiagnostic(diagnostic) { - throw new Error(ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n')) - } - }) - if (!parsed || parsed.errors.length) { - throw new Error(`Cannot parse ${config}`) - } - return { config, files: new Set(parsed.fileNames.map((file) => resolve(file))) } - } -) - -function typedFiles(directory) { - return globSync(`${directory}/**/*`, { cwd: root }).filter((file) => - /\.(?:[cm]?ts|tsx)$/.test(file) - ) -} - -describe('typecheck project coverage', () => { - it('checks the real CLI coordinator-mail integration in exactly one mixed project', () => { - const file = resolve( - root, - 'src/main/runtime/orchestration/terminal-authority/structured-sessions/structured-chat-coordinator-mail.test.ts' - ) - expect( - projects.filter((project) => project.files.has(file)).map((project) => project.config) - ).toEqual(['config/tsconfig.test.pane-launch.json']) - }) - - it('keeps CLI tests in the scheduled CLI typecheck project', () => { - const project = projects.find(({ config }) => config === 'config/tsconfig.tc.cli.json') - expect(project).toBeDefined() - const tests = typedFiles('src/cli').filter(isTest) - expect(tests.length).toBeGreaterThan(0) - expect(tests.filter((file) => !project.files.has(resolve(root, file)))).toEqual([]) - }) - - it('checks every shared test exactly once, in the scheduled Node project', () => { - const tests = typedFiles('src/shared').filter(isTest) - expect(tests.length).toBeGreaterThan(0) - const violations = tests.flatMap((file) => { - const owners = projects.filter((project) => project.files.has(resolve(root, file))) - return owners.length === 1 && owners[0].config === 'config/tsconfig.node.json' - ? [] - : [{ file, owners: owners.map((owner) => owner.config) }] - }) - expect(violations).toEqual([]) - }) - - it('keeps all shared production files in every root typecheck project', () => { - const files = typedFiles('src/shared').filter((file) => !isTest(file)) - expect(files.length).toBeGreaterThan(0) - const missing = projects.flatMap((project) => - files - .filter((file) => !project.files.has(resolve(root, file))) - .map((file) => ({ config: project.config, file })) - ) - expect(missing).toEqual([]) - }) -}) diff --git a/config/scripts/web-build/pdf-viewer-assets/pdfjs-viewer-assets-stream.test.ts b/config/scripts/web-build/pdf-viewer-assets/pdfjs-viewer-assets-stream.test.ts index 9cf2d7ba618..f3433d3ec7c 100644 --- a/config/scripts/web-build/pdf-viewer-assets/pdfjs-viewer-assets-stream.test.ts +++ b/config/scripts/web-build/pdf-viewer-assets/pdfjs-viewer-assets-stream.test.ts @@ -116,75 +116,3 @@ it('preserves successful GET bytes and removes response cleanup listeners', asyn expect(response.listeners('error')).toEqual([foreign.error]) expect(next).not.toHaveBeenCalled() }) - -it('answers HEAD without opening a file stream', () => { - const { response, next } = request('HEAD') - expect(observed.streams).toHaveLength(0) - expect(response.writableEnded).toBe(true) - expect(response.setHeader.mock.calls).toEqual([ - ['Content-Length', 1024 * 1024], - ['Content-Type', 'application/wasm'] - ]) - expect(next).not.toHaveBeenCalled() - response.destroy() -}) - -it('closes the response on source failure without leaving listeners', async () => { - const { response, source, foreign } = request() - if (!source) { - throw new Error('Missing source') - } - const closed = once(response, 'close') - source.destroy(new Error('fixture read failed')) - await closed - await expect.poll(() => source.closed).toBe(true) - expect(response.destroyed).toBe(true) - expect(response.listeners('close')).toEqual([foreign.close]) - expect(response.listeners('error')).toEqual([foreign.error]) -}) - -it('closes a source when the response fails', async () => { - const { response, source, foreign } = request() - if (!source) { - throw new Error('Missing source') - } - await once(source, 'pause') - response.destroy(new Error('fixture downstream failed')) - await expect.poll(() => source.closed).toBe(true) - expect(source.fd).toBe(null) - expect(response.listeners('close')).toEqual([foreign.close]) - expect(response.listeners('error')).toEqual([foreign.error]) -}) - -it.each([ - ['POST', '/wasm/fixture.wasm'], - ['GET', '/wasm/missing.wasm'], - ['GET', '/other/fixture.wasm'], - ['GET', '/wasm/%00.wasm'] -])('passes through %s %s without a stream', (method, url) => { - const { response, next } = request(method, url) - expect(observed.streams).toHaveLength(0) - expect(next).toHaveBeenCalledOnce() - response.destroy() -}) - -it('does not open a stream when earlier middleware resumes after response close', async () => { - const response = Object.assign(new PassThrough(), { - setHeader: vi.fn(() => { - throw new Error('ERR_HTTP_HEADERS_SENT') - }), - statusCode: 0 - }) - const closed = once(response, 'close') - response.destroy() - await closed - middleware( - // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: The middleware reads only these method/url fields. - { method: 'GET', url: '/wasm/fixture.wasm' } as IncomingMessage, - // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: The fixture implements the writable response and header fields used by this middleware. - response as unknown as ServerResponse, - vi.fn() - ) - expect(observed.streams).toHaveLength(0) - expect(response.setHeader).not.toHaveBeenCalled() -}) diff --git a/config/scripts/workflow/pr-admission/pr-ready-check-reuse.test.mjs b/config/scripts/workflow/pr-admission/pr-ready-check-reuse.test.mjs deleted file mode 100644 index 8d60ad73a61..00000000000 --- a/config/scripts/workflow/pr-admission/pr-ready-check-reuse.test.mjs +++ /dev/null @@ -1,174 +0,0 @@ -import { readFileSync } from 'node:fs' -import { afterEach, describe, expect, it, vi } from 'vitest' -import { parse } from 'yaml' -import { PR_CHECK_JOBS } from '../source-routing/pr-code-change-scope.mjs' -import { - lookupReadyCheckRun, - prCheckRunTitle, - reusablePrCheckRun -} from './pr-ready-check-reuse.mjs' - -const identity = { - number: 42, - sourceSha: 'a'.repeat(40), - workflowSha: 'b'.repeat(40), - headSha: 'c'.repeat(40), - runId: '456' -} -const passed = { - id: 123, - path: '.github/workflows/pr.yml', - event: 'pull_request', - status: 'completed', - conclusion: 'success', - head_sha: identity.headSha, - display_title: prCheckRunTitle(identity) -} -const event = { - action: 'ready_for_review', - pull_request: { number: 42, draft: false, head: { sha: identity.headSha } } -} -const env = { - GITHUB_EVENT_NAME: 'pull_request', - GITHUB_SHA: identity.sourceSha, - PR_CHECK_WORKFLOW_SHA: identity.workflowSha, - GITHUB_RUN_ID: identity.runId, - GITHUB_REPOSITORY: 'stablyai/orca', - GH_TOKEN: 'read-only-test-token' -} -const response = (runs) => ({ ok: true, json: async () => ({ workflow_runs: runs }) }) -const workflow = parse(readFileSync('.github/workflows/pr.yml', 'utf8')) - -afterEach(() => vi.restoreAllMocks()) - -describe('ready-for-review required check reuse', () => { - it('reuses a completed success only for the identical PR, merge source and workflow', () => { - expect(reusablePrCheckRun([passed], identity)).toBe(passed) - expect(reusablePrCheckRun([], identity)).toBeUndefined() - expect( - reusablePrCheckRun( - [{ ...passed, display_title: prCheckRunTitle({ ...identity, unitMode: 'selected' }) }], - identity - ) - ).toBeUndefined() - for (const key of ['number', 'sourceSha', 'workflowSha', 'headSha', 'runId']) { - const changed = key === 'number' ? 43 : key === 'runId' ? '123' : 'd'.repeat(40) - expect(reusablePrCheckRun([passed], { ...identity, [key]: changed }), key).toBeUndefined() - } - for (const key of ['number', 'sourceSha', 'workflowSha', 'headSha']) { - expect(reusablePrCheckRun([passed], { ...identity, [key]: undefined }), key).toBeUndefined() - } - }) - - it.each([ - { status: 'in_progress' }, - { status: 'queued' }, - { conclusion: 'failure' }, - { conclusion: 'cancelled' }, - { conclusion: 'skipped' }, - { event: 'push' }, - { path: '.github/workflows/other.yml' }, - { display_title: 'Previous workflow without source provenance' }, - { id: -1 } - ])('rejects unusable evidence %j', (change) => { - expect(reusablePrCheckRun([{ ...passed, ...change }], identity)).toBeUndefined() - }) - - it('bounds the read-only lookup to this workflow and PR head', async () => { - const request = vi.fn(async () => response([passed])) - expect(await lookupReadyCheckRun(env, event, request)).toBe(passed) - expect(request).toHaveBeenCalledTimes(1) - const [url, options] = request.mock.calls[0] - expect(url.origin).toBe('https://api.github.com') - expect(url.pathname).toBe('/repos/stablyai/orca/actions/workflows/pr.yml/runs') - expect(Object.fromEntries(url.searchParams)).toEqual({ - event: 'pull_request', - head_sha: identity.headSha, - status: 'success', - per_page: '20' - }) - expect(options.method).toBeUndefined() - expect(options.signal).toBeInstanceOf(AbortSignal) - }) - - it('runs ordinary pushes and draft checks without consulting old results', async () => { - const request = vi.fn() - for (const action of ['opened', 'synchronize', 'reopened', 'converted_to_draft']) { - expect(await lookupReadyCheckRun(env, { ...event, action }, request)).toBeUndefined() - } - expect( - await lookupReadyCheckRun( - env, - { ...event, pull_request: { ...event.pull_request, draft: true } }, - request - ) - ).toBeUndefined() - expect(await lookupReadyCheckRun({ ...env, GH_TOKEN: '' }, event, request)).toBeUndefined() - expect( - await lookupReadyCheckRun({ ...env, GITHUB_EVENT_NAME: 'push' }, event, request) - ).toBeUndefined() - expect(request).not.toHaveBeenCalled() - }) - - it('falls back to full checks when the API is unavailable or evidence is malformed', async () => { - vi.spyOn(console, 'log').mockImplementation(() => {}) - for (const request of [ - async () => ({ ok: false, status: 403 }), - async () => ({ ok: false, status: 429 }), - async () => ({ ok: true, json: async () => ({}) }), - async () => { - throw new Error('Network unavailable') - } - ]) { - expect(await lookupReadyCheckRun(env, event, request)).toBeUndefined() - } - expect(await lookupReadyCheckRun(env, event, async () => response([]))).toBeUndefined() - }) - - it('keeps required skips conditional on proof and leaves advisory routing eligible', () => { - expect(workflow['run-name']).toBe( - "PR ${{ github.event.pull_request.number }} | source ${{ github.sha }} | workflow ${{ github.workflow_sha }} | unit ${{ github.event.pull_request.draft && vars.ORCA_UNIT_SELECTION_MODE == 'selected' && 'selected' || 'full' }}" - ) - expect(workflow.on.pull_request.types).toContain('ready_for_review') - const detector = workflow.jobs.code_paths - expect(detector.permissions).toEqual({ contents: 'read', actions: 'read' }) - const readiness = detector.steps.find((step) => step.id === 'readiness') - expect(readiness.if).toBe("github.event.action == 'ready_for_review'") - expect(readiness.env.PR_CHECK_WORKFLOW_SHA).toBe('${{ github.workflow_sha }}') - expect(readiness.run).toBe('node config/scripts/workflow/pr-admission/pr-ready-check-reuse.mjs') - expect(detector.steps[0].with['sparse-checkout']).toContain( - '/config/scripts/workflow/pr-admission/pr-ready-check-reuse.mjs' - ) - for (const job of PR_CHECK_JOBS) { - expect(detector.outputs[job]).toBe( - `\${{ steps.readiness.outputs.reused != 'true' && steps.filter.outputs.${job} }}` - ) - } - expect(detector.outputs.should_run).toBe('${{ steps.filter.outputs.should_run }}') - for (const name of ['test_files', 'native_ime_source_changed', 'wsl_source_changed']) { - expect(detector.outputs[name]).toBe(`\${{ steps.e2e_filter.outputs.${name} }}`) - } - expect(detector.steps.find((step) => step.id === 'e2e_filter').if).toBe( - "github.event.pull_request.draft != true && steps.filter.outputs.should_run == 'true'" - ) - expect(workflow.jobs.verify.needs).toEqual([ - 'code_paths', - 'preflight', - ...new Set( - PR_CHECK_JOBS.filter((job) => job !== 'static_analysis' && job !== 'typecheck').map( - (job) => (job === 'orcad_browser' ? 'test' : job) - ) - ) - ]) - }) - - it.each(['pr-test-loc.yml'])( - 'does not rerun draft-independent %s on readiness changes', - (file) => { - const source = readFileSync(`.github/workflows/${file}`, 'utf8') - const independent = parse(source) - expect(independent.on.pull_request.types).toEqual(['opened', 'synchronize', 'reopened']) - expect(source).not.toContain('pull_request.draft') - } - ) -}) diff --git a/config/scripts/workflow/source-routing/pr-code-change-scope-daemon-protocol.test.mjs b/config/scripts/workflow/source-routing/pr-code-change-scope-daemon-protocol.test.mjs deleted file mode 100644 index a9f41a39be1..00000000000 --- a/config/scripts/workflow/source-routing/pr-code-change-scope-daemon-protocol.test.mjs +++ /dev/null @@ -1,23 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { classifyPrJobs } from './pr-code-change-scope.mjs' - -describe('daemon protocol crossing gate routing', () => { - it('runs the gate when the protocol constants change', () => { - expect(classifyPrJobs(['src/main/daemon/protocol/daemon-protocol-version.ts'])).toMatchObject({ - should_run: true, - 'cross-version-wire': true, - package: true, - package_windows: true - }) - }) - - it.each([ - 'config/scripts/daemon-protocol/schema-facts/daemon-protocol-facts.mjs', - 'config/scripts/daemon-protocol/schema-facts/daemon-protocol-revision-facts.mjs', - 'config/scripts/runtime-verification/daemon-lifecycle/git-baseline-sources.mjs', - 'config/scripts/daemon-protocol/admission/check-daemon-protocol-crossing.mjs', - 'config/scripts/release/versioning/stable-release-tags.mjs' - ])('runs the gate when its checker %s changes', (file) => { - expect(classifyPrJobs([file])).toMatchObject({ should_run: true, 'cross-version-wire': true }) - }) -}) diff --git a/config/scripts/workflow/source-routing/pr-code-change-scope-process-host.test.mjs b/config/scripts/workflow/source-routing/pr-code-change-scope-process-host.test.mjs deleted file mode 100644 index f84512eb1a4..00000000000 --- a/config/scripts/workflow/source-routing/pr-code-change-scope-process-host.test.mjs +++ /dev/null @@ -1,29 +0,0 @@ -import { expect, it } from 'vitest' -import { classifyPrJobs } from './pr-code-change-scope.mjs' - -it.each([ - 'src/packages/process-host/package.json', - 'src/packages/process-host/src/run-process.ts', - 'src/packages/process-host/src/growing-byte-buffer.ts' -])('runs the packaged surfaces and mobile web build checks for %s', (file) => { - expect(classifyPrJobs([file])).toMatchObject({ - should_run: true, - test: true, - typecheck: true, - package: true, - package_windows: true, - mobile_web_app: true - }) -}) - -it('keeps unrelated host packages out of the mobile web build checks', () => { - expect(classifyPrJobs(['src/packages/unrelated/src/index.ts']).mobile_web_app).toBe(false) -}) - -it.each([ - 'src/packages/process-host/src/run-process.ts', - 'config/scripts/desktop-distribution/runtime-verification/smoke-process-host-node18.mjs', - 'config/scripts/desktop-distribution/runtime-verification/packaged-process-host-fixture.mjs' -])('qualifies the Node 18 package floor for %s', (file) => { - expect(classifyPrJobs([file]).managed_hook_node18).toBe(true) -}) diff --git a/config/scripts/workflow/source-routing/pr-code-change-scope-test-inputs.test.mjs b/config/scripts/workflow/source-routing/pr-code-change-scope-test-inputs.test.mjs deleted file mode 100644 index 78ad2f1b87e..00000000000 --- a/config/scripts/workflow/source-routing/pr-code-change-scope-test-inputs.test.mjs +++ /dev/null @@ -1,42 +0,0 @@ -import { expect, it } from 'vitest' -import { classifyPrJobs, PR_CHECK_JOBS } from './pr-code-change-scope.mjs' - -it.each([ - 'config/scripts/workflow/source-routing/pr-code-change-scope.test.mjs', - 'config/scripts/workflow/source-routing/pr-code-change-scope-released-phone.test.mjs', - 'config/scripts/pr-package-test-paths.test.mjs' -])('keeps full units and preflight without forcing unrelated lanes for %s', (file) => { - for (const files of [[file], [file, 'AGENTS.md']]) { - const result = classifyPrJobs(files) - expect(PR_CHECK_JOBS.filter((job) => result[job])).toEqual([ - 'static_analysis', - 'typecheck', - 'test' - ]) - } - const mixed = classifyPrJobs([file, 'src/shared/git/commands/git-capability-cache.ts']) - expect(PR_CHECK_JOBS.filter((job) => mixed[job])).toEqual([ - 'static_analysis', - 'typecheck', - 'git_compatibility', - 'test', - 'package', - 'package_windows' - ]) -}) - -it.each([ - 'config/scripts/workflow/source-routing/pr-code-change-scope.mjs', - 'config/scripts/pr-code-change-scope-next.mjs', - 'config/scripts/workflow/source-routing/pr-package-test-paths.mjs', - '.github/workflows/pr.yml', - '.github/actions/install-node-dependencies/action.yml' -])('keeps every lane for routing or execution changes mixed with routing tests: %s', (file) => { - const result = classifyPrJobs([ - 'config/scripts/workflow/source-routing/pr-code-change-scope.test.mjs', - file - ]) - for (const job of PR_CHECK_JOBS) { - expect(result[job], job).toBe(true) - } -}) diff --git a/config/scripts/workflow/source-routing/pr-code-change-scope-windows-process-probe.test.mjs b/config/scripts/workflow/source-routing/pr-code-change-scope-windows-process-probe.test.mjs deleted file mode 100644 index edf1ffd9987..00000000000 --- a/config/scripts/workflow/source-routing/pr-code-change-scope-windows-process-probe.test.mjs +++ /dev/null @@ -1,36 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { classifyPrJobs } from './pr-code-change-scope.mjs' - -describe('Windows installer process probe routing', () => { - it.each([ - [], - ['config/nsis/orca-process-check.nsh'], - ['config/nsis/orca-installer-hooks.nsh'], - ['config/scripts/desktop-distribution/nsis/nsis-process-check.test.mjs'], - ['config/scripts/performance/idle-cpu/idle-cpu-process-sampling.mjs'], - ['config/scripts/performance/idle-cpu/idle-cpu-process-sampling.test.mjs'], - ['src/packages/process-host/src/run-process.ts'], - ['config/vitest.config.ts'], - ['config/scripts/test-runtime/environment/vitest-host-ports-setup.ts'], - ['config/scripts/ci/unit-selection/dependency-graph/ci-unit-files.mjs'], - ['.github/actions/install-node-dependencies/action.yml'], - ['.github/workflows/pr.yml'], - ['package.json'], - ['pnpm-lock.yaml'], - ['src/renderer/src/App.tsx', 'config/nsis/orca-process-check.nsh'] - ])('routes Windows probe inputs to their containing job for %j', (...files) => { - expect(classifyPrJobs(files)).toMatchObject({ - windows_process_probe: true, - package_windows: true - }) - }) - - it('keeps packaging and full unit tests for unrelated application changes', () => { - expect(classifyPrJobs(['src/renderer/src/App.tsx'])).toMatchObject({ - windows_process_probe: false, - package_windows: true, - test: true - }) - expect(classifyPrJobs(['docs/README.md']).windows_process_probe).toBe(false) - }) -})