Repository navigation
Stop tests from starting a real agent CLI unless asked #23824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
21f4015
test: make tests that start a real agent CLI opt-in
brennanb2025 3019888
test: type the spawnSync mock's arguments
brennanb2025 b311be0
Merge remote-tracking branch 'origin/main' into brennanb2025/real-cli…
brennanb2025 991721a
test: gate real-agent tests through their existing skip conditions
brennanb2025 d2a924c
test: gate the real OMP close probes behind the real-agent opt-in
brennanb2025 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
src/main/claude/claude-real-cli-availability-test-support.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' | ||
| import { | ||
| REAL_AGENT_TESTS_ENV, | ||
| realAgentTestsEnabled | ||
| } from '../real-agent-tests-opt-in-test-support' | ||
|
|
||
| const { spawnMock, spawnSyncMock } = vi.hoisted(() => ({ | ||
| spawnMock: vi.fn(), | ||
| spawnSyncMock: vi.fn<(program: string, args: readonly string[]) => unknown>(() => ({ | ||
| status: 1, | ||
| signal: null, | ||
| stdout: '', | ||
| stderr: '', | ||
| pid: 0 | ||
| })) | ||
| })) | ||
|
|
||
| // Why the lowest layer: nothing below this helper may start a process, whichever wrapper it uses. | ||
| vi.mock('node:child_process', async (importOriginal) => ({ | ||
| ...(await importOriginal<Record<string, unknown>>()), | ||
| spawn: spawnMock, | ||
| spawnSync: spawnSyncMock | ||
| })) | ||
|
|
||
| // Why a missing path: even a mock that failed to apply could not reach a real CLI. | ||
| vi.mock('../codex-cli/command', () => ({ | ||
| resolveClaudeCommand: () => '/nonexistent/orca-test-claude' | ||
| })) | ||
|
|
||
| async function loadAvailability() { | ||
| vi.resetModules() | ||
| return import('./claude-real-cli-availability-test-support') | ||
| } | ||
|
|
||
| describe('real Claude CLI availability', () => { | ||
| beforeEach(() => { | ||
| spawnMock.mockClear() | ||
| spawnSyncMock.mockClear() | ||
| }) | ||
|
|
||
| afterEach(() => { | ||
| vi.unstubAllEnvs() | ||
| }) | ||
|
|
||
| it('skips without spawning anything unless real-agent tests are opted into', async () => { | ||
| vi.stubEnv(REAL_AGENT_TESTS_ENV, undefined) | ||
|
|
||
| const { realClaudeAvailable, realClaudeAuthenticated, realClaudeAuthStatus } = | ||
| await loadAvailability() | ||
|
|
||
| expect(realClaudeAvailable).toBe(false) | ||
| expect(realClaudeAuthenticated).toBe(false) | ||
| expect(realClaudeAuthStatus).toBeNull() | ||
| expect(spawnSyncMock).not.toHaveBeenCalled() | ||
| expect(spawnMock).not.toHaveBeenCalled() | ||
| }) | ||
|
|
||
| it('probes the CLI once opted into', async () => { | ||
| vi.stubEnv(REAL_AGENT_TESTS_ENV, '1') | ||
|
|
||
| const { realClaudeAvailable } = await loadAvailability() | ||
|
|
||
| // The mocked probe fails, so this proves the gate, not a real CLI. | ||
| expect(realClaudeAvailable).toBe(false) | ||
| expect(spawnSyncMock).toHaveBeenCalledTimes(1) | ||
| expect(spawnSyncMock.mock.calls[0]?.[1]).toContain('--version') | ||
| }) | ||
| }) | ||
|
|
||
| describe('realAgentTestsEnabled', () => { | ||
| it.each([ | ||
| [undefined, false], | ||
| ['', false], | ||
| ['0', false], | ||
| ['true', false], | ||
| ['1', true] | ||
| ])('%j -> %s', (value, expected) => { | ||
| expect(realAgentTestsEnabled({ [REAL_AGENT_TESTS_ENV]: value })).toBe(expected) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // The one switch every test that starts a real agent CLI checks first. Those tests run the | ||
| // CLI against the developer's own config and account, so a broad local run must never start one. | ||
|
|
||
| export const REAL_AGENT_TESTS_ENV = 'ORCA_RUN_REAL_AGENT_TESTS' | ||
|
|
||
| export function realAgentTestsEnabled(env: NodeJS.ProcessEnv = process.env): boolean { | ||
| return env[REAL_AGENT_TESTS_ENV] === '1' | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
verify.env.ORCA_RUN_REAL_AGENT_TESTSalongside the other required settings.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!