Skip to content

🧪 Add dependency injection and tests for MustGetExe#103

Merged
Ven0m0 merged 2 commits into
mainfrom
test/mustgetexe-dependency-injection-15835316681249555530
May 4, 2026
Merged

🧪 Add dependency injection and tests for MustGetExe#103
Ven0m0 merged 2 commits into
mainfrom
test/mustgetexe-dependency-injection-15835316681249555530

Conversation

@Ven0m0
Copy link
Copy Markdown
Owner

@Ven0m0 Ven0m0 commented May 4, 2026

🎯 What: Adds testability and tests for the error handling path of MustGetExe which calls ExitApp and MsgBox.
📊 Coverage: Added test cases to tests/FindExe_Test.ahk that cover the successful path (returns executable string) and the failure path (calls mocked MsgBox and ExitApp with correct parameters).
Result: Improved test coverage and reliability for core process utilities without needing a specialized runner to handle hard process exits.


PR created automatically by Jules for task 15835316681249555530 started by @Ven0m0

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings May 4, 2026 01:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the testability of the shared MustGetExe helper in Lib/v2/ by allowing dependency injection of MsgBox/ExitApp, and adds tests to validate both the success and failure paths without terminating the test process.

Changes:

  • Extend MustGetExe to accept optional injected MsgBox and ExitApp callables for testing.
  • Add MustGetExe success-path and failure-path coverage in tests/FindExe_Test.ahk.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
Lib/v2/AHK_Common.ahk Adds optional mock hooks to avoid real MsgBox/ExitApp during tests.
tests/FindExe_Test.ahk Adds coverage for MustGetExe returning the resolved exe and invoking failure handlers.

Comment thread tests/FindExe_Test.ahk Outdated
Comment on lines +70 to +74
mockMsgBox(msg) {
mockState["msgBoxCalled"] := true
}

mockExitApp(code) {
- Adds `mockMsgBox` and `mockExitApp` optional parameters to `MustGetExe` in `AHK_Common.ahk` to enable testability of the exit path without killing the test runner.
- Adds comprehensive tests for `MustGetExe` to `FindExe_Test.ahk` covering both the successful lookup and the error/exit path.
- Updates CI workflow to include retry logic for Chocolatey package installations.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the MustGetExe function in Lib/v2/AHK_Common.ahk to support dependency injection for MsgBox and ExitApp, enabling more robust unit testing. New tests were added to tests/FindExe_Test.ahk to cover success and failure scenarios. However, the test implementation contains AutoHotkey v2 syntax errors, specifically regarding the placement of function definitions and the structure of the try block, which need to be addressed using anonymous functions as suggested.

Comment thread tests/FindExe_Test.ahk
Comment on lines +70 to 82
mockMsgBox := (msg) => (mockState["msgBoxCalled"] := true)
mockExitApp := (code) => (mockState["exitAppCalled"] := true, mockState["exitCode"] := code)

; Attempt to find a non-existent file with no fallbacks
try {
MustGetExe("definitely_nonexistent.exe", [], mockMsgBox, mockExitApp)
}

AssertEqual(1, mockState["msgBoxCalled"], "MustGetExe should call MsgBox on failure")
AssertEqual(1, mockState["exitAppCalled"], "MustGetExe should call ExitApp on failure")
AssertEqual(1, mockState["exitCode"], "MustGetExe should exit with code 1 on failure")

; Final Results
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This block contains two syntax errors for AutoHotkey v2:

  1. Function definitions inside control flow: mockMsgBox and mockExitApp are defined using the function name() { ... } syntax inside a try block. In AHK v2, function definitions cannot be placed inside control flow statements.
  2. Invalid try block: The try block at line 80 lacks a corresponding catch or finally block, which is a requirement in AHK v2. Furthermore, since MustGetExe does not throw exceptions, the try block is unnecessary.

To fix this while keeping the logic within the test's execution flow, you can use anonymous functions (fat arrows) assigned to variables, which are allowed inside try blocks.

    mockMsgBox := (msg) => (mockState["msgBoxCalled"] := true)
    mockExitApp := (code) => (mockState["exitAppCalled"] := true, mockState["exitCode"] := code)

    ; Attempt to find a non-existent file with no fallbacks
    MustGetExe("definitely_nonexistent.exe", [], mockMsgBox, mockExitApp)

@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented May 4, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • .github/workflows/ahk-lint-format-compile.yml - Added retry logic for chocolatey installs; looks correct
  • Lib/v2/AHK_Common.ahk - Added dependency injection params to MustGetExe; consistent with existing RequireAdmin pattern
  • tests/FindExe_Test.ahk - Added tests for success and failure paths; existing comments cover open concerns

Reviewed by kimi-k2.6-20260420 · 235,058 tokens

@Ven0m0 Ven0m0 merged commit 80576df into main May 4, 2026
4 of 6 checks passed
@Ven0m0 Ven0m0 deleted the test/mustgetexe-dependency-injection-15835316681249555530 branch May 4, 2026 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants