Files
comun/utile/Teste/_precompile.ps1
Marius Mutu 53d9f1c64a Achizitie import unificata (ROAGEST): ointroduceri, teste UI, documentatie
- import_nota / import_adauga_factura: flux unificat note contabile + articole,
  sincronizare automata, total factura automat, TVA impartit pe conturile
  creditoare ale notelor (rundele 1-31)
- runda 32: totalurile import_nota pe _label/_textbox din _baza.vcx (Arial 10),
  fara containerele clb_tx_simplu si fara bifa "Recalculeaza TVA" (recalcul
  mereu automat); "Sincronizeaza facturile secundare" mutata sub butoane
- utile/Teste: harness UI VFP headless (vfp_ui_harness.ps1, ui_harness.prg,
  precompilare, mock-uri) in radacina; suitele e2e pentru achizitia din import
  grupate in utile/Teste/achizitie_import/
- docs: flux editare text vcx/scx, testare-ui-vfp si testare-vfp-mcp (mutate
  din ROAGEST, general valabile), inventar comun, orchestrare subagenti,
  conventie GO recno, depanare testare VFP

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019DGibQKa5uK4P2TNSFFQNh
2026-07-20 00:50:18 +03:00

59 lines
2.9 KiB
PowerShell

# _precompile.ps1 -Prg <cale.prg> - regenereaza .fxp-ul target intr-un proces IZOLAT.
# De ce izolat: precompilarea (vfp9 -A ... COMPILE) atarna dupa COMPILE si e omorata; daca
# ruleaza in ACEEASI sesiune powershell care lanseaza apoi testul, lansarile ulterioare de
# vfp9 esueaza (deschid editorul in loc sa ruleze). Rulat ca proces separat (Start-Process
# -Wait din harness), nu otraveste sesiunea care lanseaza testul.
param([Parameter(Mandatory=$true)][string]$Prg)
$Vfp = 'C:\Program Files (x86)\Microsoft Visual FoxPro 9\vfp9.exe'
$Fxp = [System.IO.Path]::ChangeExtension($Prg, 'fxp')
$dir = [System.IO.Path]::GetDirectoryName($Prg)
$tmpPrg = Join-Path $dir '_compile_tmp.prg'
# prg temporar care compileaza target-ul (COMPILE cu variabila; forma cu literal in ghilimele da eroare)
Set-Content -Path $tmpPrg -Value ("lcT = `"$Prg`"`r`nCOMPILE (lcT)`r`nQUIT`r`n") -Encoding ascii
Get-Process vfp9 -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
Start-Sleep -Milliseconds 500
if (Test-Path $Fxp) { [System.IO.File]::Delete($Fxp) }
# Fara furt de focus: fereastra vfp9 a compilarii (chiar tranzitorie) e impinsa off-screen,
# la fel ca in vfp_ui_harness.ps1 (SetWindowPos HWND_BOTTOM + NOACTIVATE, x=-4000).
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class Win32UiPc {
[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-OffscreenPc([IntPtr]$Hwnd) {
if ($Hwnd -eq [IntPtr]::Zero -or -not [Win32UiPc]::IsWindow($Hwnd)) { return }
[Win32UiPc]::SetWindowPos($Hwnd, [Win32UiPc]::HWND_BOTTOM, -4000, 0, 0, 0, ([Win32UiPc]::SWP_NOSIZE -bor [Win32UiPc]::SWP_NOACTIVATE)) | Out-Null
}
$ok = $false
foreach ($try in 1..3) {
$pcProc = Start-Process -FilePath $Vfp -ArgumentList @('-A', "`"$tmpPrg`"") -PassThru
$dl = (Get-Date).AddSeconds(30)
$pcHwnd = [IntPtr]::Zero
while (-not (Test-Path $Fxp) -and (Get-Date) -lt $dl) {
if ($pcHwnd -eq [IntPtr]::Zero -and -not $pcProc.HasExited) {
$pcProc.Refresh()
if ($pcProc.MainWindowHandle -ne [IntPtr]::Zero) { $pcHwnd = $pcProc.MainWindowHandle }
}
Push-OffscreenPc $pcHwnd
Start-Sleep -Milliseconds 300
}
Start-Sleep -Seconds 3
Get-Process vfp9 -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
Start-Sleep -Seconds 1
if (Test-Path $Fxp) { $ok = $true; break }
}
foreach ($f in @($tmpPrg, [System.IO.Path]::ChangeExtension($tmpPrg, 'fxp'))) {
if (Test-Path $f) { try { [System.IO.File]::Delete($f) } catch {} }
}
if ($ok) { exit 0 } else { exit 1 }