#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.cmd — exits with %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" 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