Files
comun/utile/Teste/facturare_unificat/probe_run.ps1
Marius Mutu 8e022d332e #13: formular de facturare unificat - etapa curenta
Squash al branch-ului de lucru plan13-s2.

Clase: ofacturare (nucleul formularului unificat), ofacturare_comun,
ferestre_cere_date, ocomenzi, caut_ora (lista de preturi in combo-urile de
cautare), omodificari.

Programe: ofacturare impartit - ofacturare_antet, ofacturare_rutare_scriere si
ogrid_latimi sunt fisiere noi; oproceduri_facturare primeste discountul pe linie
si cota standard de TVA cand articolul nu are cota pe politica.

Documentatie: capcana SQLExec no_data_found, conventia de encoding, depanarea
testelor VFP si regulile de lucru - conflictele cu modificarile venite din alte
proiecte sunt rezolvate pastrand ambele parti.

Loguri de rulare a testelor scoase din versionare; testele raman.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkyjGyrV2S7932om4kfSiK
2026-09-09 21:38:25 +03:00

79 lines
3.5 KiB
PowerShell

# probe_run.ps1 - lansator minimal, fara capturi, pentru probe_totaluri.prg.
# Precompileaza izolat (_precompile.ps1), lanseaza .fxp cu fereastra impinsa off-screen
# (SWP_NOACTIVATE), asteapta out\probe_totaluri.log (semnal final scris de proba), apoi
# opreste procesul. O singura rulare vfp9.exe per apel.
$ErrorActionPreference = 'Stop'
$TestDir = $PSScriptRoot
$TestPrg = Join-Path $TestDir 'probe_totaluri.prg'
$TestFxp = Join-Path $TestDir 'probe_totaluri.fxp'
$OutLog = Join-Path $TestDir 'out\probe_totaluri.log'
$SyncDir = Join-Path $TestDir 'uisync_probe'
$DoneFile = Join-Path $SyncDir 'done.txt'
$Vfp = 'C:\Program Files (x86)\Microsoft Visual FoxPro 9\vfp9.exe'
$Precompile = Join-Path (Split-Path $TestDir -Parent) '_precompile.ps1'
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class Win32UiProbe {
[DllImport("user32.dll")]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
[DllImport("user32.dll")]
public static extern bool IsWindow(IntPtr hWnd);
public static readonly IntPtr HWND_BOTTOM = new IntPtr(1);
public const uint SWP_NOSIZE = 0x0001;
public const uint SWP_NOACTIVATE = 0x0010;
}
"@
function Push-Offscreen([IntPtr]$Hwnd) {
if ($Hwnd -eq [IntPtr]::Zero -or -not [Win32UiProbe]::IsWindow($Hwnd)) { return }
[Win32UiProbe]::SetWindowPos($Hwnd, [Win32UiProbe]::HWND_BOTTOM, -4000, 0, 0, 0, ([Win32UiProbe]::SWP_NOSIZE -bor [Win32UiProbe]::SWP_NOACTIVATE)) | Out-Null
}
function Stop-VfpProprii([string]$Marker) {
Get-CimInstance Win32_Process -Filter "Name='vfp9.exe'" -ErrorAction SilentlyContinue | ForEach-Object {
if ($_.CommandLine -and $_.CommandLine.ToLower().Contains($Marker.ToLower())) {
Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue
}
}
}
if (-not (Test-Path (Join-Path $TestDir 'out'))) { New-Item -ItemType Directory -Path (Join-Path $TestDir 'out') | Out-Null }
if (-not (Test-Path $SyncDir)) { New-Item -ItemType Directory -Path $SyncDir | Out-Null }
Get-ChildItem -Path $SyncDir -File -ErrorAction SilentlyContinue | Remove-Item -Force -ErrorAction SilentlyContinue
if (Test-Path $OutLog) { Remove-Item $OutLog -Force }
Stop-VfpProprii $TestDir
Start-Sleep -Milliseconds 500
Write-Host "Precompilez: $Precompile -Prg $TestPrg"
$pc = Start-Process powershell -WindowStyle Hidden -ArgumentList @('-ExecutionPolicy','Bypass','-File', "`"$Precompile`"", '-Prg', "`"$TestPrg`"") -Wait -PassThru
Start-Sleep -Seconds 2
Stop-VfpProprii $TestDir
Start-Sleep -Seconds 2
if (-not (Test-Path $TestFxp)) { Write-Warning "Nu s-a generat $TestFxp"; exit 1 }
Write-Host "Lansez VFP: $Vfp -A $TestFxp"
$proc = Start-Process -FilePath $Vfp -ArgumentList @('-A', "`"$TestFxp`"") -PassThru
$hwnd = [IntPtr]::Zero
$deadline = (Get-Date).AddSeconds(150)
$doneSeen = $false
while ((Get-Date) -lt $deadline) {
if (-not $proc.HasExited) {
$proc.Refresh()
if ($hwnd -eq [IntPtr]::Zero -and $proc.MainWindowHandle -ne [IntPtr]::Zero) { $hwnd = $proc.MainWindowHandle }
Push-Offscreen $hwnd
}
if (Test-Path $DoneFile) { $doneSeen = $true; break }
if ($proc.HasExited) { break }
Start-Sleep -Milliseconds 500
}
if ($doneSeen) {
Write-Host "done.txt detectat: $((Get-Content $DoneFile -Raw).Trim())"
} else {
Write-Warning "TIMEOUT sau proces iesit fara done.txt."
}
Start-Sleep -Milliseconds 800
if ($proc -and -not $proc.HasExited) { try { $proc.Kill() } catch {} }
Stop-VfpProprii $TestDir
Write-Host "GATA."