diff --git a/git_sync.ps1 b/git_sync.ps1 index 968e275..ee0e7c4 100644 --- a/git_sync.ps1 +++ b/git_sync.ps1 @@ -26,7 +26,8 @@ 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 - -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). @@ -59,6 +60,10 @@ .PARAMETER OrphanCleanup 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 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'), # 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'), + # 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 = '', [int]$TimeoutSeconds = 60, [int]$MaxDb2Mb = 5, @@ -280,6 +287,8 @@ if (-not $SubDir) { $allText = Get-ChildItem -LiteralPath $ProjectRoot -Recurse -File -ErrorAction SilentlyContinue | Where-Object { $script:TextExts.ContainsKey($_.Extension.ToLower()) } foreach ($t in $allText) { + $tRel = Get-RelPath $t.FullName + if (@($OrphanExempt | Where-Object { $tRel -like $_ }).Count -gt 0) { continue } $tExt = $t.Extension.ToLower() $binExt = $script:TextExts[$tExt] $base = [IO.Path]::GetFileNameWithoutExtension($t.Name) @@ -291,7 +300,7 @@ if (-not $SubDir) { $isOrphan = $true # tabela a iesit din lista } if ($isOrphan) { - $orphansDeleted += (Get-RelPath $t.FullName) + $orphansDeleted += $tRel if ($OrphanCleanup -and -not $NoOrphanCleanup) { Remove-Item -LiteralPath $t.FullName -Force -ErrorAction SilentlyContinue } } } diff --git a/test_git_sync.ps1 b/test_git_sync.ps1 index d3d8c62..6137da7 100644 --- a/test_git_sync.ps1 +++ b/test_git_sync.ps1 @@ -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) {