Files
orca/src/main/windows-process-tree-kill.test.ts
T
OrcaWin 2847bbe9e8 [comment audit] Consolidate completed code comment cleanup
Combine the completed comment cleanup from 319 stacked PRs into one change against `main`, so the full CI suite validates the combined result once. This replaces the previous audit stack; no additional audit work is included.

The change shortens redundant comments across 2,753 source and shell-snapshot files (25,235 net lines removed). Conflicts preserve current-main executable code. Runtime behavior, test assertions, directives, licenses, generated notices, SAFETY rationales, and compatibility markers are preserved. The audit tracker remains local, outside the repository.

Validation:
- Equivalent source/emitted AST and executable tokens across all 2,750 source files, with separate checks for embedded shell, SQL, JavaScript, CSS, and generated fixtures.
- Identical executable lines in the three shell snapshots; protected comments unchanged.
- Changed-code quality gate passed with no new findings.
- 358 tests passed, 2 skipped across 23 focused test files.
- `git diff --check` passed.
2026-10-23 13:15:45 -07:00

59 lines
1.8 KiB
TypeScript

import { describe, expect, it, vi } from 'vitest'
import {
terminateWindowsProcessTree,
WINDOWS_PROCESS_TREE_KILL_TIMEOUT_MS
} from './windows-process-tree-kill'
describe('terminateWindowsProcessTree', () => {
it('invokes taskkill /T /F with timeout and windowsHide', async () => {
const execFileImpl = vi.fn(
(
_cmd: string,
_args: readonly string[],
_options: { timeout?: number; windowsHide?: boolean },
callback: (error: Error | null) => void
) => {
callback(null)
}
)
await expect(
terminateWindowsProcessTree(1234, {
execFileImpl: execFileImpl as never
})
).resolves.toBe(true)
expect(execFileImpl).toHaveBeenCalledWith(
'taskkill',
['/pid', '1234', '/T', '/F'],
{
timeout: WINDOWS_PROCESS_TREE_KILL_TIMEOUT_MS,
windowsHide: true
},
expect.any(Function)
)
})
it('resolves false, never throws, when taskkill reports failure (already dead)', async () => {
const execFileImpl = vi.fn(
(
_cmd: string,
_args: readonly string[],
_options: { timeout?: number; windowsHide?: boolean },
callback: (error: Error | null) => void
) => {
callback(new Error('not found'))
}
)
await expect(
terminateWindowsProcessTree(55, { execFileImpl: execFileImpl as never })
).resolves.toBe(false)
})
it('skips taskkill for invalid pids', async () => {
const execFileImpl = vi.fn()
await terminateWindowsProcessTree(0, { execFileImpl: execFileImpl as never })
await terminateWindowsProcessTree(-1, { execFileImpl: execFileImpl as never })
expect(execFileImpl).not.toHaveBeenCalled()
await expect(terminateWindowsProcessTree(0)).resolves.toBe(false)
})
})