git_sync.ps1: -OrphanExempt, texte fara binar prin design

Un text .??2 al carui binar e gitignored si se genereaza local din text (txt2vcx) nu e
orfan, dar era raportat ca atare la fiecare sync. Pattern-urile din -OrphanExempt sunt
sarite inainte de verificarea binarului, deci nici raportate nici sterse la
-OrphanCleanup. Implicit acopera stub-ul de formular verificare.sc2 din testele
headless de achizitie import.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EiizMcQA6NEYCftpqCtPtC
This commit is contained in:
2026-08-03 22:49:45 +03:00
parent 57c4a63d06
commit 339ad0a4bc
2 changed files with 45 additions and 3 deletions

View File

@@ -9,6 +9,8 @@
valide din aceeasi rulare se convertesc totusi;
(D) protectia binarului - dupa orice rulare, toate binarele fixture-ului sunt byte-identice
(SHA256 inainte/dupa). Verificat si dupa fiecare rulare din A/B/C.
(E) scutire roundtrip - fisierul din -RoundtripExempt produce text fara garda de roundtrip;
(F) scutire orfani - textul din -OrphanExempt nu e raportat ca orfan, restul da.
Fixture: copie a celui mai mic .vcx+.vct real din Clase si a setului Locale (dbf+memo+indecsi+
container dbc) din proiectul sursa. NU se scrie nimic in proiectul sursa - doar se citeste/copiaza.
@@ -35,11 +37,15 @@ function Assert([bool]$cond, [string]$msg) {
# --- Ruleaza git_sync.ps1 ca proces copil si parseaza sumarul + orfanii + exit code ---
function Invoke-GitSync {
param([string]$Fixture, [string[]]$DbfList, [string[]]$Exempt, [int]$TimeoutSeconds = 30)
param([string]$Fixture, [string[]]$DbfList, [string[]]$Exempt, [string[]]$OrphanExempt, [int]$TimeoutSeconds = 30)
# -Command (nu -File): powershell.exe -File colapseaza 'a','b' intr-un singur token, DbfList ar fi gol
$dbfLit = if ($DbfList -and $DbfList.Count) { '@(' + (($DbfList | ForEach-Object { "'" + $_ + "'" }) -join ',') + ')' } else { '@()' }
$exLit = if ($Exempt -and $Exempt.Count) { '@(' + (($Exempt | ForEach-Object { "'" + $_ + "'" }) -join ',') + ')' } else { '@()' }
$cmd = "& '$script:GitSync' -ProjectRoot '$Fixture' -DbfList $dbfLit -RoundtripExempt $exLit -TimeoutSeconds $TimeoutSeconds"
# fara -OrphanExempt explicit ramane valoarea implicita din git_sync.ps1 (testul F o verifica)
if ($OrphanExempt) {
$cmd += ' -OrphanExempt @(' + (($OrphanExempt | ForEach-Object { "'" + $_ + "'" }) -join ',') + ')'
}
# EAP=Continue local: git_sync ruleaza FoxBin2Prg care scrie pe stderr (ex. 'not a table');
# sub EAP=Stop, capturarea 2>&1 a acelui stderr ar arunca NativeCommandError si ar opri testul.
$prevEAP = $ErrorActionPreference
@@ -200,6 +206,32 @@ function Test-Exempt {
} finally { Remove-Fixture $fx }
}
function Test-OrphanExempt {
Write-Host "`n--- (F) scutire orfani: textul din -OrphanExempt nu e raportat, restul da ---"
$fx = New-Fixture 'orphanexempt'
try {
# textul scutit implicit: stub-ul de test din COMUN, al carui .scx e gitignored si generat local
$stubDir = Join-Path $fx 'COMUN\utile\Teste\achizitie_import\stub_verificare'
New-Item -ItemType Directory -Path $stubDir -Force | Out-Null
$stub = Join-Path $stubDir 'verificare.sc2'
Set-Content -LiteralPath $stub -Value '* stub de test, binarul se genereaza local' -Encoding Ascii
# martor: text fara binar in afara scutirii -> trebuie raportat in continuare
$ctrl = Join-Path $fx 'Clase\_orfan.sc2'
Set-Content -LiteralPath $ctrl -Value '* text orfan fara binar corespondent' -Encoding Ascii
$r = Invoke-GitSync -Fixture $fx -DbfList @('Locale\locale.dbf')
$orf = $r.Orphans -join ';'
Assert ($r.Exit -eq 0) "F: rulare curata cu scutire de orfani (exit=$($r.Exit))"
Assert ($orf -notmatch '(?i)verificare\.sc2') "F: textul scutit NU e raportat ca orfan"
Assert (Test-Path -LiteralPath $stub) "F: textul scutit ramane pe disc"
Assert ($orf -match '(?i)_orfan\.sc2') "F: orfanul din afara scutirii e raportat in continuare"
# cu pattern explicit care nu-l acopera, stub-ul redevine orfan raportat
$r2 = Invoke-GitSync -Fixture $fx -DbfList @('Locale\locale.dbf') -OrphanExempt @('*\nimic_care_nu_exista.sc2')
Assert ((($r2.Orphans -join ';')) -match '(?i)verificare\.sc2') "F: fara pattern-ul potrivit, stub-ul e raportat ca orfan"
} finally { Remove-Fixture $fx }
}
# ============================== MAIN ==============================
if (-not (Test-Path -LiteralPath $script:GitSync)) { throw "Nu gasesc git_sync.ps1: $script:GitSync" }
if (-not (Test-Path -LiteralPath $SourceProject)) { throw "Proiect sursa inexistent: $SourceProject" }
@@ -210,6 +242,7 @@ Test-Orphans
Test-PartialFailure
Test-BinaryProtection
Test-Exempt
Test-OrphanExempt
Write-Host "`n=== REZULTAT ==="
if ($script:Failures.Count -eq 0) {