$ErrorActionPreference='Stop' $taskRoot='C:\laragon\www\portal-investidor' $taskQa=Join-Path $taskRoot 'storage\app\private\investmoz-v2\portal-audit\onboarding-qa-internal-20261011_191450' $taskOut=Join-Path $taskRoot 'outputs\investmoz-staff-preparation-20261012' $taskPhp='C:\laragon\bin\php\php-8.5.11-Win32-vs17-x64\php.exe' $taskPython='C:\Users\macbook\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe' if(Get-NetTCPConnection -State Listen -LocalPort 18119 -ErrorAction SilentlyContinue){throw 'Dedicated QA test port occupied'} & $taskPhp (Join-Path $taskOut 'c130-http-fixture-qa.php') prepare if($LASTEXITCODE -ne 0){throw 'QA fixture preparation failed'} $taskInfo=[Diagnostics.ProcessStartInfo]::new() $taskInfo.FileName=$taskPhp $taskInfo.Arguments='-d zend.exception_ignore_args=1 -S 127.0.0.1:18119 -t "'+(Join-Path $taskQa 'public')+'" "'+(Join-Path $taskQa 'tools\internal-router.php')+'"' $taskInfo.WorkingDirectory=$taskQa $taskInfo.UseShellExecute=$false $taskInfo.CreateNoWindow=$true $taskInfo.RedirectStandardOutput=$true $taskInfo.RedirectStandardError=$true foreach($taskKey in @{ PORTAL_PROFILE_ADMINISTRATION_ENABLED='true'; PORTAL_PROFILE_ACCESS_ENABLED='false'; PORTAL_OPPORTUNITY_DASHBOARD_ACCESS_ENABLED='false'; PORTAL_OPPORTUNITY_SPECIALIZED_DRAFTS_ENABLED='false'; PORTAL_NOTIFICATIONS_ENABLED='false'; APP_URL='http://127.0.0.1:18119'; SESSION_COOKIE='investmoz_c130_ephemeral_qa'; SESSION_SECURE_COOKIE='false'; MAIL_MAILER='array' }.GetEnumerator()){$taskInfo.EnvironmentVariables[$taskKey.Key]=$taskKey.Value} $taskProcess=[Diagnostics.Process]::Start($taskInfo) $taskReadOut=$taskProcess.StandardOutput.ReadToEndAsync() $taskReadErr=$taskProcess.StandardError.ReadToEndAsync() try{ $taskStarted=$false foreach($taskAttempt in 1..30){Start-Sleep -Milliseconds 200;$taskListener=Get-NetTCPConnection -State Listen -LocalPort 18119 -ErrorAction SilentlyContinue;if($taskListener){if($taskListener.OwningProcess -ne $taskProcess.Id){throw 'QA listener process differs'};$taskStarted=$true;break};if($taskProcess.HasExited){break}} if(-not $taskStarted){throw 'Ephemeral QA server did not start'} & $taskPython -X utf8 (Join-Path $taskOut 'test-c130-http-qa.py') if($LASTEXITCODE -ne 0){throw 'C130 HTTP QA test failed'} }finally{ # Only the child created here; no other PHP, Apache or active service is touched. if(-not $taskProcess.HasExited){$taskProcess.Kill();$taskProcess.WaitForExit()} [void]$taskReadOut.Result;[void]$taskReadErr.Result $taskProcess.Dispose() }