🧪 [Testing] Add timeout error path test for WaitForWindow#104
🧪 [Testing] Add timeout error path test for WaitForWindow#104
Conversation
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Pull request overview
This PR updates the shared AutoHotkey v2 window helper to fix WaitForWindow's timeout handling and adds a corresponding test path. It fits into the repo's shared Lib/v2/ utilities by correcting behavior in a reusable window-management helper and extending the manual test harness under ahk/.
Changes:
- Refactors
WaitForWindowinLib/v2/WindowManager.ahkto use an injectable API wrapper instead of catchingTimeoutError. - Changes timeout detection to treat
WinWait(...) = 0as the timeout case. - Adds a timeout-focused test in
ahk/test_WindowManager.ahkusing a mocked window API.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
Lib/v2/WindowManager.ahk |
Refactors WaitForWindow to use dependency injection and return false when WinWait times out. |
ahk/test_WindowManager.ahk |
Adds a mock WinWait implementation and a new timeout regression test for WaitForWindow. |
| WaitForWindow(winTitle, timeout := 30, api := "") { | ||
| if !api | ||
| api := SystemWindowAPI() | ||
|
|
||
| return api.WinWait(winTitle, , timeout) != 0 |
| TestToggleFakeFullscreen_MakeFullscreen() | ||
| TestToggleFakeFullscreen_RestoreWindow() | ||
|
|
||
| TestGetMonitorAtPos_InsideMonitor() | ||
| TestGetMonitorAtPos_OutsideMonitors() | ||
| TestGetMonitorAtPos_MultipleMonitors() | ||
| TestWaitForWindow_Timeout() | ||
|
|
||
| FileOpen("*", "w `n").Write("All tests complete.`n") | ||
| ExitApp |
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Reviewed by kimi-k2.6-20260420 · 363,582 tokens |
There was a problem hiding this comment.
Code Review
This pull request refactors the WaitForWindow function in WindowManager.ahk to support dependency injection, facilitating better unit testing. It also introduces a mock implementation for WinWait and a new test case, TestWaitForWindow_Timeout, to verify timeout behavior. Feedback was provided regarding the test runner in test_WindowManager.ahk, which currently does not verify the return values of test functions, meaning failures would not be correctly propagated to CI environments.
| TestToggleFakeFullscreen_MakeFullscreen() | ||
| TestToggleFakeFullscreen_RestoreWindow() | ||
|
|
||
| TestGetMonitorAtPos_InsideMonitor() | ||
| TestGetMonitorAtPos_OutsideMonitors() | ||
| TestGetMonitorAtPos_MultipleMonitors() | ||
| TestWaitForWindow_Timeout() |
There was a problem hiding this comment.
The test runner in this script does not verify the return values of the test functions. If a test fails (returns false), the script will still proceed to print "All tests complete." and exit with a success code (0). This makes the tests ineffective for CI environments where a non-zero exit code is required to signal failure. Since this PR adds a new test, it's a good opportunity to ensure failures are correctly propagated.
if !TestToggleFakeFullscreen_MakeFullscreen()
ExitApp(1)
if !TestToggleFakeFullscreen_RestoreWindow()
ExitApp(1)
if !TestGetMonitorAtPos_InsideMonitor()
ExitApp(1)
if !TestGetMonitorAtPos_OutsideMonitors()
ExitApp(1)
if !TestGetMonitorAtPos_MultipleMonitors()
ExitApp(1)
if !TestWaitForWindow_Timeout()
ExitApp(1)
🎯 What:
WaitForWindowfunction inLib/v2/WindowManager.ahkwas improperly catchingTimeoutError, whichWinWaitin AutoHotkey v2 no longer throws (it returns 0 instead on timeout).WaitForWindowto support Dependency Injection for its API calls.ahk/test_WindowManager.ahk.📊 Coverage:
WaitForWindowpropagates thefalsereturn state.✨ Result:
PR created automatically by Jules for task 1221782000402455162 started by @Ven0m0