fix(tests): lower ValidateRange minimums and use .ps1 fake vmrun for Pester

This commit is contained in:
Simone
2026-05-10 22:50:25 +02:00
parent a3a24199b3
commit fa2acc4b46
4 changed files with 18 additions and 14 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ param(
[string] $VmrunPath = 'C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe',
[ValidateRange(5, 60)]
[ValidateRange(1, 60)]
[int] $GracefulTimeoutSeconds = 15
)
+1 -1
View File
@@ -157,7 +157,7 @@ function Run-Test {
Write-Host ""
Write-Host "╔════════════════════════════════════════════════════════╗" -ForegroundColor Yellow
Write-Host "║ §3.3 E2E Test: In-VM Git Clone vs Host-side Zip ║" -ForegroundColor Yellow
Write-Host "║ §3.3 E2E Test: In-VM Git Clone vs Host-side Zip " -ForegroundColor Yellow
Write-Host "╚════════════════════════════════════════════════════════╝" -ForegroundColor Yellow
$baselineResult = $null
+2 -2
View File
@@ -43,10 +43,10 @@ param(
[ValidatePattern('^((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$')]
[string] $IPAddress,
[ValidateRange(30, 600)]
[ValidateRange(3, 600)]
[int] $TimeoutSeconds = 300,
[ValidateRange(3, 30)]
[ValidateRange(1, 30)]
[int] $PollIntervalSeconds = 5,
[string] $VmrunPath = 'C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe',
+14 -10
View File
@@ -9,18 +9,22 @@ BeforeAll {
$script:CloneBaseDir = Join-Path $env:TEMP "CI-Tests-CloneBase-$PID"
New-Item -ItemType Directory -Path $script:CloneBaseDir -Force | Out-Null
# Fake vmrun.cmd — exits with %FAKE_VMRUN_EXIT% (default 0)
# Fake vmrun.ps1 — exits with $env:FAKE_VMRUN_EXIT (default 0)
# On success it also creates the destination VMX so the post-clone Test-Path passes.
$script:FakeVmrun = Join-Path $env:TEMP "fake-vmrun-$PID.cmd"
# Using .ps1 instead of .cmd avoids Windows cmd redirect limitations inside if blocks.
$script:FakeVmrun = Join-Path $env:TEMP "fake-vmrun-$PID.ps1"
Set-Content $script:FakeVmrun -Value @'
@echo off
if "%FAKE_VMRUN_EXIT%"=="" ( set _exit=0 ) else ( set _exit=%FAKE_VMRUN_EXIT% )
if "%_exit%"=="0" (
REM Create the destination VMX file so the caller's Test-Path check passes.
REM The destination path is the 4th positional arg (after -T ws clone <template>).
echo. > %5
)
exit /b %_exit%
# Args: -T ws clone <template> <dst_vmx> linked -snapshot <snapshot>
$exitCode = if ($env:FAKE_VMRUN_EXIT) { [int]$env:FAKE_VMRUN_EXIT } else { 0 }
if ($exitCode -eq 0) {
# Create the destination VMX (5th positional arg) so Test-Path in caller passes.
# Real vmrun creates the clone dir+file; we must do the same here.
$dstVmx = $args[4] # -T ws clone <tmpl> <dst> ...
$dstDir = Split-Path $dstVmx -Parent
if (-not (Test-Path $dstDir)) { New-Item -ItemType Directory -Path $dstDir -Force | Out-Null }
Set-Content $dstVmx ''
}
exit $exitCode
'@
# Fake template VMX — just needs to exist