#Requires -Version 5.1 <# .SYNOPSIS Pester v5 tests for scripts/New-BuildVM.ps1 #> BeforeAll { $script:ScriptPath = Join-Path $PSScriptRoot '..\scripts\New-BuildVM.ps1' $script:CloneBaseDir = Join-Path $env:TEMP "CI-Tests-CloneBase-$PID" New-Item -ItemType Directory -Path $script:CloneBaseDir -Force | Out-Null # 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. # 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 @' # Args: -T ws clone