-
Notifications
You must be signed in to change notification settings - Fork 0
Stabilize timeout-sensitive runtime and CLI tests #199
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7c1058e
Stabilize runtime and CLI timeout-sensitive tests
bbopen 5b6c853
test: address PR review feedback
bbopen 8fd9e37
fix(runtime): preserve POSIX path aliases
bbopen 48adce8
fix(runtime): avoid empty PATH entries
bbopen 5ce60ae
test: make ParallelProcessor worker-isolation test deterministic
bbopen 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
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 |
|---|---|---|
|
|
@@ -425,12 +425,15 @@ def get_bad(): | |
| if (!pythonAvailable || !isBridgeScriptAvailable()) return; | ||
|
|
||
| // Give the bridge enough time to recover (worker quarantine/replacement) after a timeout. | ||
| bridge = new NodeBridge({ scriptPath, timeoutMs: 1000 }); | ||
| const timeoutMs = 3000; | ||
| const lateResponseWaitMs = 1500; | ||
| const sleepSeconds = (timeoutMs + lateResponseWaitMs) / 1000; | ||
| bridge = new NodeBridge({ scriptPath, timeoutMs }); | ||
|
|
||
| await expect(bridge.call('time', 'sleep', [1.5])).rejects.toThrow(/timed out/i); | ||
| await expect(bridge.call('time', 'sleep', [sleepSeconds])).rejects.toThrow(/timed out/i); | ||
|
|
||
| // Wait for the Python process to eventually respond to the timed-out request. | ||
| await new Promise(resolve => setTimeout(resolve, 800)); | ||
| // Wait for the timed-out worker to emit its stale response before verifying recovery. | ||
| await new Promise(resolve => setTimeout(resolve, lateResponseWaitMs + 250)); | ||
|
|
||
| // Note: With the unified bridge, timed-out workers are quarantined and replaced | ||
| // per ADR-0001 (#101). The important thing is that the bridge recovers and works. | ||
|
|
@@ -1170,7 +1173,8 @@ def get_bad(): | |
| expect(venvEnv).toBe(venvDir); | ||
|
|
||
| const pathEnv = await bridge.call<string | null>('os', 'getenv', ['PATH']); | ||
| expect(pathEnv?.split(delimiter)[0]).toBe(binDir); | ||
| const pathEntries = (pathEnv ?? '').split(delimiter).filter(Boolean); | ||
| expect(pathEntries).toContain(binDir); | ||
| } finally { | ||
| await bridge?.dispose(); | ||
| if (tempDir) { | ||
|
|
@@ -1182,6 +1186,99 @@ def get_bad(): | |
| }, | ||
| testTimeout | ||
| ); | ||
|
|
||
| it( | ||
| 'should preserve distinct lowercase path env overrides on POSIX', | ||
| async () => { | ||
| if (process.platform === 'win32') return; | ||
|
|
||
| const pythonAvailable = await isPythonAvailable(); | ||
| if (!pythonAvailable || !isBridgeScriptAvailable()) return; | ||
|
|
||
| let tempDir: string | undefined; | ||
| try { | ||
| tempDir = await mkdtemp(join(tmpdir(), 'tywrap-venv-')); | ||
| const venvDir = join(tempDir, 'fake-venv'); | ||
| const binDir = join(venvDir, getVenvBinDir()); | ||
| await mkdir(binDir, { recursive: true }); | ||
|
|
||
| const customPathAlias = '/custom/app/config/path'; | ||
| const scriptAbsolutePath = join(process.cwd(), scriptPath); | ||
| bridge = new NodeBridge({ | ||
| scriptPath: scriptAbsolutePath, | ||
| pythonPath: defaultPythonPath, | ||
| cwd: tempDir, | ||
| virtualEnv: 'fake-venv', | ||
| env: { path: customPathAlias }, | ||
| timeoutMs: defaultTimeoutMs, | ||
| }); | ||
|
|
||
| const pathEnv = await bridge.call<string | null>('os', 'getenv', ['PATH']); | ||
| const pathEntries = (pathEnv ?? '').split(delimiter).filter(Boolean); | ||
| expect(pathEntries).toContain(binDir); | ||
|
|
||
| const lowercasePathEnv = await bridge.call<string | null>('os', 'getenv', ['path']); | ||
| expect(lowercasePathEnv).toBe(customPathAlias); | ||
|
Comment on lines
+1216
to
+1221
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assert that This currently proves the lowercase Proposed test tightening const pathEnv = await bridge.call<string | null>('os', 'getenv', ['PATH']);
const pathEntries = (pathEnv ?? '').split(delimiter).filter(Boolean);
expect(pathEntries).toContain(binDir);
+ expect(pathEntries).toContain(customPathAlias);
const lowercasePathEnv = await bridge.call<string | null>('os', 'getenv', ['path']);
expect(lowercasePathEnv).toBe(customPathAlias);🤖 Prompt for AI Agents |
||
| } finally { | ||
| await bridge?.dispose(); | ||
| if (tempDir) { | ||
| await rm(tempDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }); | ||
| } | ||
| } | ||
| }, | ||
| testTimeout | ||
| ); | ||
|
|
||
| it( | ||
| 'should not append an empty PATH segment when PATH is blank', | ||
| async () => { | ||
| const pythonAvailable = await isPythonAvailable(); | ||
| if (!pythonAvailable || !isBridgeScriptAvailable()) return; | ||
|
|
||
| let tempDir: string | undefined; | ||
| try { | ||
| const { execFile } = await import('child_process'); | ||
| const { promisify } = await import('util'); | ||
| const execFileAsync = promisify(execFile); | ||
| const locator = process.platform === 'win32' ? 'where' : 'which'; | ||
| const { stdout } = await execFileAsync(locator, [defaultPythonPath], { | ||
| encoding: 'utf-8', | ||
| }); | ||
| const resolvedPythonPath = String(stdout) | ||
| .split(/\r?\n/) | ||
| .find(candidate => candidate.trim().length > 0) | ||
| ?.trim(); | ||
| if (!resolvedPythonPath) { | ||
| throw new Error(`Failed to locate ${defaultPythonPath}`); | ||
| } | ||
|
|
||
| tempDir = await mkdtemp(join(tmpdir(), 'tywrap-venv-')); | ||
| const venvDir = join(tempDir, 'fake-venv'); | ||
| const binDir = join(venvDir, getVenvBinDir()); | ||
| await mkdir(binDir, { recursive: true }); | ||
|
|
||
| const scriptAbsolutePath = join(process.cwd(), scriptPath); | ||
| bridge = new NodeBridge({ | ||
| scriptPath: scriptAbsolutePath, | ||
| pythonPath: resolvedPythonPath, | ||
| cwd: tempDir, | ||
| virtualEnv: 'fake-venv', | ||
| env: { PATH: '' }, | ||
| timeoutMs: defaultTimeoutMs, | ||
| }); | ||
|
|
||
| const pathEnv = await bridge.call<string | null>('os', 'getenv', ['PATH']); | ||
| expect(pathEnv).toBe(binDir); | ||
| } finally { | ||
| await bridge?.dispose(); | ||
| if (tempDir) { | ||
| await rm(tempDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }); | ||
| } | ||
| } | ||
| }, | ||
| testTimeout | ||
| ); | ||
|
|
||
| }); | ||
|
|
||
| describe('Performance Characteristics', () => { | ||
|
|
||
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.
Updating every
path-cased key unconditionally will clobber distinct environment variables on case-sensitive platforms: whenvirtualEnvis set, a user-providedpath/Pathvariable (used for app config, not executable lookup) is overwritten with the computedPATHvalue. This behavior was introduced bysetPathValueand can break subprocess behavior for callers that intentionally pass bothPATHand another differently-cased key on Linux/macOS; the alias synchronization should be gated to Windows only.Useful? React with 👍 / 👎.