Files
opencode-manager/backend/test/utils/process.test.ts
Chris Scott 53238a6324 feat(git): extend source control with worktrees, stashes, conflicts and identities
- Create a worktree from a new or existing branch
- Integrate a worktree branch into a target branch by merge commit or cherry-pick, with continue/abort on conflicts
- Delete a worktree with keep, delete-local, or delete-local-and-remote branch options, using safe branch deletion for unmerged branches
- Add a stash tab (list, push, apply, pop, drop) shared across a repository and its worktrees
- Rename and delete branches, optionally deleting the remote branch and updating scheduled base branches
- Detect in-progress merge, rebase, cherry-pick and revert operations and hand conflicts to an agent session
- Generate commit messages from staged changes with the default model
- Add a default git identity and saved per-repository identities written to git config
- Unify git error mapping behind a typed error and one route helper; consolidate git mutations and cache invalidation
- Update repository docs
2026-10-03 21:59:00 -04:00

44 lines
1.7 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { executeCommand } from '../../src/utils/process'
describe('executeCommand signal handling', () => {
it('reports a signal-terminated child as a non-zero exit code when exit codes are ignored', async () => {
const result = await executeCommand(['sh', '-c', 'kill -KILL $$'], {
ignoreExitCode: true,
silent: true,
})
const structured = typeof result === 'string' ? { exitCode: 0, stdout: result, stderr: '' } : result
expect(structured.exitCode).not.toBe(0)
expect(structured.stderr).toContain('Command terminated by signal SIGKILL')
})
it('rejects a signal-terminated child when exit codes are enforced', async () => {
await expect(executeCommand(['sh', '-c', 'kill -KILL $$'], { silent: true })).rejects.toThrow(
'Command failed with signal SIGKILL',
)
})
it('resolves a zero exit code as success when exit codes are ignored', async () => {
const result = await executeCommand(['sh', '-c', 'true'], { ignoreExitCode: true, silent: true })
expect(result).toEqual({ exitCode: 0, stdout: '', stderr: '' })
})
it('truncates stdout at maxOutputChars and resolves instead of rejecting', async () => {
const result = await executeCommand(
['sh', '-c', 'i=0; while [ $i -lt 1000 ]; do printf "0123456789"; i=$((i+1)); done'],
{ maxOutputChars: 100, silent: true },
)
expect(typeof result).toBe('string')
expect(result).toHaveLength(100)
})
it('returns the full stdout when it stays within maxOutputChars', async () => {
const result = await executeCommand(['sh', '-c', 'printf "hello"'], { maxOutputChars: 100, silent: true })
expect(result).toBe('hello')
})
})