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

@@ -26,7 +26,8 @@
Curatare orfani: textele .??2 fara binar corespondent (binar sters din SVN) si .db2-urile ale Curatare orfani: textele .??2 fara binar corespondent (binar sters din SVN) si .db2-urile ale
caror tabele au IESIT din lista -DbfList sunt DOAR RAPORTATE implicit; se sterg numai cu caror tabele au IESIT din lista -DbfList sunt DOAR RAPORTATE implicit; se sterg numai cu
-OrphanCleanup explicit. -OrphanCleanup explicit. Textele din -OrphanExempt sunt sarite de la verificare (text fara
binar prin design).
Toate invocarile FoxBin2Prg.EXE trec prin Invoke-FoxBin2PrgSafe (timeout + taskkill). Toate invocarile FoxBin2Prg.EXE trec prin Invoke-FoxBin2PrgSafe (timeout + taskkill).
@@ -59,6 +60,10 @@
.PARAMETER OrphanCleanup .PARAMETER OrphanCleanup
Sterge efectiv textele orfane. Implicit orfanii sunt DOAR raportati, nu stersi. Sterge efectiv textele orfane. Implicit orfanii sunt DOAR raportati, nu stersi.
.PARAMETER OrphanExempt
Pattern-uri (-like, relative la ProjectRoot) de texte .??2 care NU sunt orfani chiar fara binar
langa ele: binarul e gitignored si se genereaza local din text (txt2vcx), textul e sursa.
.EXAMPLE .EXAMPLE
powershell -ExecutionPolicy Bypass -File D:\ROA\UTIL\foxbin2prg\git_sync.ps1 -ProjectRoot D:\ROA\ROACONT powershell -ExecutionPolicy Bypass -File D:\ROA\UTIL\foxbin2prg\git_sync.ps1 -ProjectRoot D:\ROA\ROACONT
#> #>
@@ -76,6 +81,8 @@ param(
'utile\ListProperty\lproperty.dbf','utile\hpdf\*.dbf','utile\hpdf\ReportOutput\*.dbf'), 'utile\ListProperty\lproperty.dbf','utile\hpdf\*.dbf','utile\hpdf\ReportOutput\*.dbf'),
# clase FFC/third-party cu #INCLUDE: roundtrip izolat = fals-negativ; editare doar in IDE, fara write-back # clase FFC/third-party cu #INCLUDE: roundtrip izolat = fals-negativ; editare doar in IDE, fara write-back
[string[]]$RoundtripExempt = @('COMUN\clase\accessibility.vcx','COMUN\clase\oinventar.vcx','COMUN\clase\_gdiplus.vcx','COMUN\clase\_reportlistener.vcx','COMUN\utile\foxcharts\foxcharts.vcx','COMUN\utile\web\_webview.vcx'), [string[]]$RoundtripExempt = @('COMUN\clase\accessibility.vcx','COMUN\clase\oinventar.vcx','COMUN\clase\_gdiplus.vcx','COMUN\clase\_reportlistener.vcx','COMUN\utile\foxcharts\foxcharts.vcx','COMUN\utile\web\_webview.vcx'),
# texte a caror sursa de adevar e textul: binarul e gitignored si se genereaza local, nu sunt orfani
[string[]]$OrphanExempt = @('*utile\Teste\achizitie_import\stub_verificare\verificare.sc2'),
[string]$SubDir = '', [string]$SubDir = '',
[int]$TimeoutSeconds = 60, [int]$TimeoutSeconds = 60,
[int]$MaxDb2Mb = 5, [int]$MaxDb2Mb = 5,
@@ -280,6 +287,8 @@ if (-not $SubDir) {
$allText = Get-ChildItem -LiteralPath $ProjectRoot -Recurse -File -ErrorAction SilentlyContinue | $allText = Get-ChildItem -LiteralPath $ProjectRoot -Recurse -File -ErrorAction SilentlyContinue |
Where-Object { $script:TextExts.ContainsKey($_.Extension.ToLower()) } Where-Object { $script:TextExts.ContainsKey($_.Extension.ToLower()) }
foreach ($t in $allText) { foreach ($t in $allText) {
$tRel = Get-RelPath $t.FullName
if (@($OrphanExempt | Where-Object { $tRel -like $_ }).Count -gt 0) { continue }
$tExt = $t.Extension.ToLower() $tExt = $t.Extension.ToLower()
$binExt = $script:TextExts[$tExt] $binExt = $script:TextExts[$tExt]
$base = [IO.Path]::GetFileNameWithoutExtension($t.Name) $base = [IO.Path]::GetFileNameWithoutExtension($t.Name)
@@ -291,7 +300,7 @@ if (-not $SubDir) {
$isOrphan = $true # tabela a iesit din lista $isOrphan = $true # tabela a iesit din lista
} }
if ($isOrphan) { if ($isOrphan) {
$orphansDeleted += (Get-RelPath $t.FullName) $orphansDeleted += $tRel
if ($OrphanCleanup -and -not $NoOrphanCleanup) { Remove-Item -LiteralPath $t.FullName -Force -ErrorAction SilentlyContinue } if ($OrphanCleanup -and -not $NoOrphanCleanup) { Remove-Item -LiteralPath $t.FullName -Force -ErrorAction SilentlyContinue }
} }
} }

View File

@@ -9,6 +9,8 @@
valide din aceeasi rulare se convertesc totusi; valide din aceeasi rulare se convertesc totusi;
(D) protectia binarului - dupa orice rulare, toate binarele fixture-ului sunt byte-identice (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. (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+ 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. 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 --- # --- Ruleaza git_sync.ps1 ca proces copil si parseaza sumarul + orfanii + exit code ---
function Invoke-GitSync { 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 # -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 { '@()' } $dbfLit = if ($DbfList -and $DbfList.Count) { '@(' + (($DbfList | ForEach-Object { "'" + $_ + "'" }) -join ',') + ')' } else { '@()' }
$exLit = if ($Exempt -and $Exempt.Count) { '@(' + (($Exempt | 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" $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'); # 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. # sub EAP=Stop, capturarea 2>&1 a acelui stderr ar arunca NativeCommandError si ar opri testul.
$prevEAP = $ErrorActionPreference $prevEAP = $ErrorActionPreference
@@ -200,6 +206,32 @@ function Test-Exempt {
} finally { Remove-Fixture $fx } } 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 ============================== # ============================== MAIN ==============================
if (-not (Test-Path -LiteralPath $script:GitSync)) { throw "Nu gasesc git_sync.ps1: $script:GitSync" } 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" } if (-not (Test-Path -LiteralPath $SourceProject)) { throw "Proiect sursa inexistent: $SourceProject" }
@@ -210,6 +242,7 @@ Test-Orphans
Test-PartialFailure Test-PartialFailure
Test-BinaryProtection Test-BinaryProtection
Test-Exempt Test-Exempt
Test-OrphanExempt
Write-Host "`n=== REZULTAT ===" Write-Host "`n=== REZULTAT ==="
if ($script:Failures.Count -eq 0) { if ($script:Failures.Count -eq 0) {