# test_repro_anaf_path_nfjson.ps1 - rulare headless a testului de reproducere pentru
# "ANAF nu a raspuns - verificare sarita" in ROAGEST (COMUN\UTILE\NFJSON lipsa din SET PATH).
# Rulare:  powershell -ExecutionPolicy Bypass -File test_repro_anaf_path_nfjson.ps1
$ErrorActionPreference = 'Stop'
$Teste = $PSScriptRoot
$Prg = Join-Path $Teste 'test_repro_anaf_path_nfjson.prg'
$Fxp = [IO.Path]::ChangeExtension($Prg, '.fxp')
$Log = Join-Path $Teste 'test_repro_anaf_path_nfjson_log.txt'
$Vfp = 'C:\Program Files (x86)\Microsoft Visual FoxPro 9\vfp9.exe'

Remove-Item $Fxp, $Log -ErrorAction SilentlyContinue
$p = Start-Process -FilePath $Vfp -ArgumentList '-A', '-T', "`"$Prg`"" -PassThru
if (-not $p.WaitForExit(240000)) {
    $p.Kill()
    throw 'TIMEOUT: testul nu s-a terminat in 240s'
}
if (-not (Test-Path $Log)) { throw "Lipseste logul $Log" }
Get-Content $Log
