Skip to content

Commit aad1546

Browse files
Ven0m0Copilotkilo-code-bot[bot]claude
authored
Refactor test infrastructure and update workflow dependencies (#105)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: kilo-code-bot[bot] <240665456+kilo-code-bot[bot]@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9eb34bd commit aad1546

8 files changed

Lines changed: 83 additions & 28 deletions

File tree

.github/workflows/ahk-lint-format-compile.yml

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
lint:
1717
runs-on: windows-latest
1818
steps:
19-
- uses: actions/checkout@v6
19+
- uses: actions/checkout@v4
2020

2121
- name: Install AutoHotkey v1.1 (Portable)
2222
run: choco install autohotkey.portable --version=1.1.36.01 -y
@@ -83,8 +83,7 @@ jobs:
8383
$syntaxErrors += $rel
8484
}
8585
86-
# Format check
87-
$content = Get-Content $_.FullName -Raw
86+
# Format check (reuses $content already read above)
8887
$problems = @()
8988
if (($content -match "(?m)^\t") -and ($content -match "(?m)^ ")) { $problems += "mixed indent" }
9089
if ($content -match "[ \t]+`r?`n") { $problems += "trailing space" }
@@ -112,3 +111,58 @@ jobs:
112111
exit 1
113112
}
114113
shell: pwsh
114+
115+
- name: Run Tests
116+
run: |
117+
function Test-IsAhkV2Script {
118+
param(
119+
[Parameter(Mandatory = $true)]
120+
[string]$Path
121+
)
122+
123+
$header = Get-Content -Path $Path -TotalCount 20 -ErrorAction SilentlyContinue
124+
return $header -match '^\s*#Requires\s+AutoHotkey\s+v2(\.0)?\b'
125+
}
126+
127+
$ahkV2 = "$env:ProgramFiles\AutoHotkey\v2\AutoHotkey64.exe"
128+
$searchRoots = @("tests", "ahk", "Lib") | Where-Object { Test-Path $_ }
129+
$testFiles = @()
130+
131+
foreach ($root in $searchRoots) {
132+
$testFiles += Get-ChildItem -Path $root -Recurse -Filter *.ahk -File |
133+
Where-Object {
134+
($_.Name -like "test_*" -or $_.Name -like "*_Test.ahk") -and
135+
(Test-IsAhkV2Script -Path $_.FullName)
136+
}
137+
}
138+
139+
$failed = @()
140+
141+
if (-not $testFiles) {
142+
Write-Host "No AutoHotkey v2 test files found under tests/ or ahk/."
143+
exit 0
144+
}
145+
146+
foreach ($tf in $testFiles) {
147+
$rel = $tf.FullName -replace [regex]::Escape("$(Get-Location)\"), ""
148+
$proc = Start-Process -FilePath $ahkV2 -ArgumentList "`"$($tf.FullName)`"" -PassThru -NoNewWindow
149+
if (!$proc.WaitForExit(30000)) {
150+
$proc.Kill()
151+
Write-Host "❌ $rel - timed out" -ForegroundColor Red
152+
$failed += $rel
153+
} elseif ($proc.ExitCode -ne 0) {
154+
Write-Host "❌ $rel - exit $($proc.ExitCode)" -ForegroundColor Red
155+
$failed += $rel
156+
} else {
157+
Write-Host "✓ $rel" -ForegroundColor Green
158+
}
159+
}
160+
161+
Write-Host "`nRan: $($testFiles.Count) | Failed: $($failed.Count)"
162+
163+
if ($failed) {
164+
Write-Host "`nFailed tests:" -ForegroundColor Red
165+
$failed | % { Write-Host " $_" }
166+
exit 1
167+
}
168+
shell: pwsh

.github/workflows/build-cached.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
build-release:
1717
runs-on: windows-latest
1818
steps:
19-
- uses: actions/checkout@v6
19+
- uses: actions/checkout@v4
2020

2121
- name: Cache AutoHotkey and Ahk2Exe
2222
uses: actions/cache@v5
@@ -44,7 +44,8 @@ jobs:
4444
Expand-Archive "$env:TEMP\Ahk2Exe.zip" -DestinationPath "C:\AutoHotkey-Portable\Compiler" -Force
4545
$requiredFiles = @(
4646
"C:\AutoHotkey-Portable\Compiler\Ahk2Exe.exe",
47-
"C:\AutoHotkey-Portable\Compiler\AutoHotkeySC.bin"
47+
"C:\AutoHotkey-Portable\Compiler\Unicode 32-bit.bin",
48+
"C:\AutoHotkey-Portable\Compiler\Unicode 64-bit.bin"
4849
)
4950
$missingFiles = $requiredFiles | Where-Object { -not (Test-Path $_) }
5051
if ($missingFiles) {
@@ -88,7 +89,7 @@ jobs:
8889
shell: pwsh
8990

9091
- name: Create Release
91-
uses: softprops/action-gh-release@v3
92+
uses: softprops/action-gh-release@v2
9293
with:
9394
files: release/*.exe
9495
fail_on_unmatched_files: true

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
build-release:
1717
runs-on: windows-latest
1818
steps:
19-
- uses: actions/checkout@v6
19+
- uses: actions/checkout@v4
2020

2121
- name: Install Scoop
2222
shell: pwsh
@@ -89,7 +89,7 @@ jobs:
8989
shell: pwsh
9090

9191
- name: Create Release
92-
uses: softprops/action-gh-release@v3
92+
uses: softprops/action-gh-release@v2
9393
with:
9494
files: release/*.exe
9595
fail_on_unmatched_files: true

.github/workflows/copilot-setup-steps.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ jobs:
1616
copilot-setup-steps:
1717
runs-on: ubuntu-latest
1818
steps:
19-
- uses: actions/checkout@v6
19+
- uses: actions/checkout@v4
2020

21-
- uses: actions/setup-node@v6
21+
- uses: actions/setup-node@v4
2222
with:
2323
node-version: "24"
2424

.github/workflows/powershell.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
name: PSScriptAnalyzer
3030
runs-on: ubuntu-latest
3131
steps:
32-
- uses: actions/checkout@v6
32+
- uses: actions/checkout@v4
3333

3434
- name: Run PSScriptAnalyzer
3535
uses: microsoft/psscriptanalyzer-action@7a0da25f33985767f15f93140306528900744195
@@ -44,6 +44,6 @@ jobs:
4444

4545
# Upload the SARIF file generated in the previous step
4646
- name: Upload SARIF results file
47-
uses: github/codeql-action/upload-sarif@v4
47+
uses: github/codeql-action/upload-sarif@v3
4848
with:
4949
sarif_file: results.sarif

Lib/v2/WindowManager.ahk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
; WindowManager – borderless/fullscreen utilities
44

5-
static STYLE_DECORATIONS := 0xEC0000 ; title/menu/frame/sysmodal combined
6-
static STYLE_UNDECORATED := -0xEC0000
5+
global STYLE_DECORATIONS := "+0xEC0000" ; title/menu/frame/sysmodal combined
6+
global STYLE_UNDECORATED := "-0xEC0000"
77

88
ToggleFakeFullscreen(winTitle := "A", api := "") {
99
if !api

ahk/Keys.ahk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#Requires AutoHotkey v2.0
2+
#SingleInstance Force
3+
#Include ..\Lib\v2\AHK_Common.ahk
24

3-
#Include %A_ScriptDir%\..\Lib\v2\AHK_Common.ahk
4-
InitScript(true, false, true) ; UIA required, no admin, optimize
5-
5+
InitScript(true, false, true)
66
SetTitleMatchMode(3)
77
SetNumLockState("AlwaysOn")
88
SetCapsLockState("AlwaysOff")

ahk/test_WindowManager.ahk

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,22 @@ TestToggleFakeFullscreen_MakeFullscreen() {
5555
; Verify calls
5656
if (mockApi.calls.Length != 3) {
5757
FileOpen("*", "w `n").Write("Fail: Expected 3 calls, got " mockApi.calls.Length "`n")
58-
return false
58+
ExitApp(1)
5959
}
6060

6161
if (mockApi.calls[1].method != "WinGetStyle") {
6262
FileOpen("*", "w `n").Write("Fail: First call was not WinGetStyle`n")
63-
return false
63+
ExitApp(1)
6464
}
6565

6666
if (mockApi.calls[2].method != "WinSetStyle") {
6767
FileOpen("*", "w `n").Write("Fail: Second call was not WinSetStyle`n")
68-
return false
68+
ExitApp(1)
6969
}
7070

7171
if (mockApi.calls[3].method != "WinMove") {
7272
FileOpen("*", "w `n").Write("Fail: Third call was not WinMove`n")
73-
return false
73+
ExitApp(1)
7474
}
7575

7676
FileOpen("*", "w `n").Write("Pass: MakeFullscreen`n")
@@ -86,17 +86,17 @@ TestToggleFakeFullscreen_RestoreWindow() {
8686
; Verify calls
8787
if (mockApi.calls.Length != 3) {
8888
FileOpen("*", "w `n").Write("Fail: Expected 3 calls, got " mockApi.calls.Length "`n")
89-
return false
89+
ExitApp(1)
9090
}
9191

9292
if (mockApi.calls[2].method != "WinSetStyle") {
9393
FileOpen("*", "w `n").Write("Fail: Second call was not WinSetStyle`n")
94-
return false
94+
ExitApp(1)
9595
}
9696

9797
if (mockApi.calls[3].method != "WinRestore") {
9898
FileOpen("*", "w `n").Write("Fail: Third call was not WinRestore`n")
99-
return false
99+
ExitApp(1)
100100
}
101101

102102
FileOpen("*", "w `n").Write("Pass: RestoreWindow`n")
@@ -112,7 +112,7 @@ TestGetMonitorAtPos_InsideMonitor() {
112112
res := GetMonitorAtPos(500, 500, mockApi)
113113
if (res != 1) {
114114
FileOpen("*", "w `n").Write("Fail: Expected 1, got " res "`n")
115-
return false
115+
ExitApp(1)
116116
}
117117
FileOpen("*", "w `n").Write("Pass: GetMonitorAtPos_InsideMonitor`n")
118118
return true
@@ -127,7 +127,7 @@ TestGetMonitorAtPos_OutsideMonitors() {
127127
res := GetMonitorAtPos(-100, 500, mockApi)
128128
if (res != -1) {
129129
FileOpen("*", "w `n").Write("Fail: Expected -1, got " res "`n")
130-
return false
130+
ExitApp(1)
131131
}
132132
FileOpen("*", "w `n").Write("Pass: GetMonitorAtPos_OutsideMonitors`n")
133133
return true
@@ -143,7 +143,7 @@ TestGetMonitorAtPos_MultipleMonitors() {
143143
res := GetMonitorAtPos(-500, 500, mockApi)
144144
if (res != 2) {
145145
FileOpen("*", "w `n").Write("Fail: Expected 2, got " res "`n")
146-
return false
146+
ExitApp(1)
147147
}
148148
FileOpen("*", "w `n").Write("Pass: GetMonitorAtPos_MultipleMonitors`n")
149149
return true
@@ -157,4 +157,4 @@ TestGetMonitorAtPos_OutsideMonitors()
157157
TestGetMonitorAtPos_MultipleMonitors()
158158

159159
FileOpen("*", "w `n").Write("All tests complete.`n")
160-
ExitApp
160+
ExitApp(0)

0 commit comments

Comments
 (0)