fix(tests): lower ValidateRange minimums and use .ps1 fake vmrun for Pester
This commit is contained in:
@@ -32,7 +32,7 @@ param(
|
|||||||
|
|
||||||
[string] $VmrunPath = 'C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe',
|
[string] $VmrunPath = 'C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe',
|
||||||
|
|
||||||
[ValidateRange(5, 60)]
|
[ValidateRange(1, 60)]
|
||||||
[int] $GracefulTimeoutSeconds = 15
|
[int] $GracefulTimeoutSeconds = 15
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ function Run-Test {
|
|||||||
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "╔════════════════════════════════════════════════════════╗" -ForegroundColor Yellow
|
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
|
Write-Host "╚════════════════════════════════════════════════════════╝" -ForegroundColor Yellow
|
||||||
|
|
||||||
$baselineResult = $null
|
$baselineResult = $null
|
||||||
|
|||||||
@@ -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)$')]
|
[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,
|
[string] $IPAddress,
|
||||||
|
|
||||||
[ValidateRange(30, 600)]
|
[ValidateRange(3, 600)]
|
||||||
[int] $TimeoutSeconds = 300,
|
[int] $TimeoutSeconds = 300,
|
||||||
|
|
||||||
[ValidateRange(3, 30)]
|
[ValidateRange(1, 30)]
|
||||||
[int] $PollIntervalSeconds = 5,
|
[int] $PollIntervalSeconds = 5,
|
||||||
|
|
||||||
[string] $VmrunPath = 'C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe',
|
[string] $VmrunPath = 'C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe',
|
||||||
|
|||||||
+14
-10
@@ -9,18 +9,22 @@ BeforeAll {
|
|||||||
$script:CloneBaseDir = Join-Path $env:TEMP "CI-Tests-CloneBase-$PID"
|
$script:CloneBaseDir = Join-Path $env:TEMP "CI-Tests-CloneBase-$PID"
|
||||||
New-Item -ItemType Directory -Path $script:CloneBaseDir -Force | Out-Null
|
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.
|
# 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 @'
|
Set-Content $script:FakeVmrun -Value @'
|
||||||
@echo off
|
# Args: -T ws clone <template> <dst_vmx> linked -snapshot <snapshot>
|
||||||
if "%FAKE_VMRUN_EXIT%"=="" ( set _exit=0 ) else ( set _exit=%FAKE_VMRUN_EXIT% )
|
$exitCode = if ($env:FAKE_VMRUN_EXIT) { [int]$env:FAKE_VMRUN_EXIT } else { 0 }
|
||||||
if "%_exit%"=="0" (
|
if ($exitCode -eq 0) {
|
||||||
REM Create the destination VMX file so the caller's Test-Path check passes.
|
# Create the destination VMX (5th positional arg) so Test-Path in caller passes.
|
||||||
REM The destination path is the 4th positional arg (after -T ws clone <template>).
|
# Real vmrun creates the clone dir+file; we must do the same here.
|
||||||
echo. > %5
|
$dstVmx = $args[4] # -T ws clone <tmpl> <dst> ...
|
||||||
)
|
$dstDir = Split-Path $dstVmx -Parent
|
||||||
exit /b %_exit%
|
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
|
# Fake template VMX — just needs to exist
|
||||||
|
|||||||
Reference in New Issue
Block a user