Skip to content

fix: add timeout protection to PowerShell Pester test runner - #406

Merged
boyingliu01 merged 1 commit into
mainfrom
fix/powershell-test-timeout
Aug 27, 2026
Merged

boyingliu01 merged 1 commit into
mainfrom
fix/powershell-test-timeout

Conversation

@boyingliu01

Copy link
Copy Markdown
Owner

变更说明

修复 PowerShell 适配器 run_tests / run_coverage 调用 Invoke-Pester 无超时保护的问题。挂起的 Pester 测试会无限阻塞 git commit

问题背景

githooks/adapters/powershell.shrun_tests 直接调用 Invoke-Pester,无任何超时。若某个测试点源(dot-source)了脚本、脚本体执行 WMI/注册表/计划任务扫描(如 Get-CimInstance Win32_ServiceGet-ScheduledTask),该测试挂起,Invoke-Pester 永不返回 → git commit 无限阻塞。

修复

用 GNU timeout(默认 300s,可用 XP_GATE_POWERSHELL_TEST_TIMEOUT_S 覆盖)包裹 Invoke-Pester。超时后打印清晰警告并返回非零退出码,而非永久挂起。

验证

  • 3 位 Delphi 专家(architecture/technical/feasibility)全部 APPROVED,共识 100%
  • 在 Windows 11 + Git Bash 实测:GNU timeout 检测正确、exit 124 语义确认、多行 PowerShell 脚本字符串通过 $@ 完整转发
  • pre-commit 全部门禁通过

相关

@github-actions

Copy link
Copy Markdown

XP-Gate Quality Report

Quality Gate Status: failure
Overall Score: 0.0/10
Gates Passed: 0/6

Quality checks have completed for this pull request.

⚠️ Some quality gates have failed. Please address the issues before merging.

@github-actions

Copy link
Copy Markdown

XP-Gate Quality Report

Quality Gate Status: failure
Overall Score: 0.0/10
Gates Passed: 0/6

Quality checks have completed for this pull request.

⚠️ Some quality gates have failed. Please address the issues before merging.

@boyingliu01
boyingliu01 force-pushed the fix/powershell-test-timeout branch from 4e90967 to b69feb2 Compare August 27, 2026 05:23
@boyingliu01
boyingliu01 deployed to development August 27, 2026 05:23 — with GitHub Actions Active
@github-actions

Copy link
Copy Markdown

XP-Gate Quality Report

Quality Gate Status: success
Overall Score: 10.0/10
Gates Passed: 6/6

Quality checks have completed for this pull request.

All quality gates have passed. Ready for review!

PowerShell adapter's run_tests/run_coverage invoked Invoke-Pester with no
timeout. A hanging Pester test (e.g. a test that dot-sources a script whose
body performs WMI/registry/scheduled-task scans) would block 'git commit'
forever.

Wrap Invoke-Pester in GNU timeout (default 300s, override via
XP_GATE_POWERSHELL_TEST_TIMEOUT_S). On timeout, print a clear warning and
return non-zero instead of hanging indefinitely.

Fixes #405.

Also bumps VERSION to 0.18.5.1 and syncs package.json (resolves pre-existing
VERSION/package.json drift).
@boyingliu01
boyingliu01 force-pushed the fix/powershell-test-timeout branch from b69feb2 to 4e8c01e Compare August 27, 2026 06:11
@boyingliu01
boyingliu01 merged commit 0848858 into main Aug 27, 2026
10 checks passed
@boyingliu01
boyingliu01 deployed to development August 27, 2026 06:11 — with GitHub Actions Active
@github-actions

Copy link
Copy Markdown

XP-Gate Quality Report

Quality Gate Status: success
Overall Score: 10.0/10
Gates Passed: 6/6

Quality checks have completed for this pull request.

All quality gates have passed. Ready for review!

@boyingliu01
boyingliu01 deleted the fix/powershell-test-timeout branch August 30, 2026 15:26
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.

PowerShell Pester 测试无超时保护,挂起测试无限阻塞 git commit

1 participant