fix(tests): resolve test environment compatibility/brittleness issues for CI builds#24
Open
jamesjmartin wants to merge 2 commits into
Open
fix(tests): resolve test environment compatibility/brittleness issues for CI builds#24jamesjmartin wants to merge 2 commits into
jamesjmartin wants to merge 2 commits into
Conversation
- Convert OpenCodeLogicTest to extend BasePlatformTestCase for proper IntelliJ Application context instead of plain JUnit with Proxy mocks - Fix Windows binary detection in RealProcessIntegrationTest by searching for opencode.cmd/.bat/.exe alongside the bare filename - Fix forceVfsRefresh to skip non-existent files and use async refresh, preventing blocking directory scans on the background thread - Fix SendSelectionToTerminalActionTest flake: replace thread-hopping async paste pipeline with synchronous dispatch and CountDownLatch
…rom Runnable to plain lambda to allign with IntelliJ SDK
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fix
./gradlew buildfailures on Windows and in CI by addressing three test environment compatibility issues: missing IntelliJ Application context in unit tests, missing Windows binary extension in PATH search, and a blocking VFS refresh pattern.Changes
OpenCodeLogicTest — Proper IntelliJ test harness
Replaced the plain JUnit class with
java.lang.reflect.Proxymock ofProjectwithBasePlatformTestCase, which provides a real IntelliJ Application context. Without this,NotificationGroupManager.getInstance()and other platform APIs threw exceptions, disconnecting the SSE listener before diffs could be fetched, causing test timeouts.Also moved temporary test file creation from
java.io.tmpdirtoproject.basePath, matching wherePathUtil.resolveProjectPathresolves relative paths.RealProcessIntegrationTest — Windows binary detection
On Windows, npm installs
opencode.cmd(a batch wrapper), not a bareopencodefile. The PATH search now checks platform-appropriate filenames:opencode.cmd,opencode.bat,opencode.exe,opencodeopencode(unchanged)forceVfsRefresh — Async, skip non-existent files
Two changes:
refreshIoFilesfrom synchronous to asynchronous to prevent blocking the background task thread.SendSelectionToTerminalActionTest — Eliminate race condition
The test had a flaky race on Linux CI:
actionPerformed>>schedulePasteAttempt>> scheduled executor (100ms) >>invokeLater(EDT) >>pasteToTerminal>>AppExecutorService.submit(HTTP call) >>FakeOpenCodeServer. Four thread hops meant the HTTP call sometimes didn't complete within the 2-second polling window.Fix — two parts:
OpenCodeService.kt: Extracted the schedule+invokeLater chain intopasteDispatch, an injectable test hook.schedulePasteAttemptnow delegates topasteDispatchinstead of hardcoding the executor/EDT calls.FakeOpenCodeServer.kt+ test: AddedCountDownLatch(1)(promptLatch) counted down in the POST handler afterreceivedPrompts.add(body). The test overridespasteDispatch = { task -> task() }to runpasteToTerminalsynchronously during the action, then blocks onlatch.await(5, TimeUnit.SECONDS)— no busy-polling, no thread scheduling lottery.Verification