@@ -47,6 +47,30 @@ function Assert-ExitCode([string]$name, [int]$expected, [scriptblock]$block) {
4747}
4848
4949$fixture = Join-Path $Shelf " scripts\tests\fixtures\minimal-docs-repo"
50+ $trackedIgnoredFixture = Join-Path $Shelf " scripts\tests\fixtures\tracked-ignored-repo"
51+ $deltaDryRunSlug = " delta-orchestrator-dry-run"
52+ $fixtureSlug = " minimal-docs-repo"
53+ $shelfDryRunSlug = " shelf-orchestrator-dry-run"
54+
55+ function Remove-GeneratedTestArtifacts {
56+ $generatedPaths = @ (
57+ (Join-Path $Shelf " audits\$deltaDryRunSlug " ),
58+ (Join-Path $Shelf " audits\$fixtureSlug " ),
59+ (Join-Path $Shelf " audits\$shelfDryRunSlug " ),
60+ (Join-Path $fixture " .git" ),
61+ (Join-Path $trackedIgnoredFixture " .git" ),
62+ (Join-Path $trackedIgnoredFixture " local-only.secret" ),
63+ (Join-Path $Shelf " scripts\tests\fixtures\quickstart-isolated-repo\out" )
64+ )
65+
66+ foreach ($generatedPath in $generatedPaths ) {
67+ if (Test-Path - LiteralPath $generatedPath ) {
68+ Remove-Item - LiteralPath $generatedPath - Recurse - Force
69+ }
70+ }
71+ }
72+
73+ Remove-GeneratedTestArtifacts
5074
5175Assert-ExitCode " validate-regulation-index" 0 {
5276 & (Join-Path $Shelf " scripts\validate-regulation-index.ps1" ) - ShelfPath $Shelf
@@ -68,14 +92,13 @@ Assert-ExitCode "check-gitignore-consistency on fixture" 0 {
6892 & (Join-Path $Shelf " scripts\check-gitignore-consistency.ps1" ) - RepoPath $fixture
6993}
7094
71- $trackedIgnoredFixture = Join-Path $Shelf " scripts\tests\fixtures\tracked-ignored-repo"
7295if (-not (Test-Path (Join-Path $trackedIgnoredFixture " .git" ))) {
7396 Push-Location $trackedIgnoredFixture
7497 Set-Content - Path " local-only.secret" - Value " fixture-secret=tracked-but-ignored" - NoNewline
75- git init | Out-Null
76- git add README.md LICENSE SECURITY.md .gitignore
77- git add -f local- only.secret
78- git - c user.email= " fixture@test" - c user.name= " fixture" commit - m " init tracked-ignored fixture" | Out-Null
98+ git - c " safe.directory= $trackedIgnoredFixture " init | Out-Null
99+ git - c " safe.directory= $trackedIgnoredFixture " add README.md LICENSE SECURITY.md .gitignore
100+ git - c " safe.directory= $trackedIgnoredFixture " add -f local- only.secret
101+ git - c " safe.directory= $trackedIgnoredFixture " - c user.email= " fixture@test" - c user.name= " fixture" commit - m " init tracked-ignored fixture" | Out-Null
79102 Pop-Location
80103}
81104
@@ -92,19 +115,18 @@ Assert-Pass "collect-audit-evidence completes after blocked gitignore" {
92115$presentHead = (Invoke-TestGit - RepoPath $Shelf rev- parse HEAD)
93116# v1.1.4 -> present always includes audit.manifest.yml change (v1.1.5); stable across future commits
94117$manifestPriorHead = (Invoke-TestGit - RepoPath $Shelf rev- parse ' v1.1.4^{commit}' )
95-
96118Assert-ExitCode " run-delta-audit allowed (no changes)" 0 {
97119 & (Join-Path $Shelf " scripts\run-delta-audit.ps1" ) `
98120 - RepoPath $Shelf `
99- - AuditSlug " github-optimization " `
121+ - AuditSlug $deltaDryRunSlug `
100122 - PriorHead $presentHead `
101123 - SkipShelfValidation
102124}
103125
104126Assert-ExitCode " run-delta-audit invalidates manifest change" 2 {
105127 & (Join-Path $Shelf " scripts\run-delta-audit.ps1" ) `
106128 - RepoPath $Shelf `
107- - AuditSlug " github-optimization " `
129+ - AuditSlug $deltaDryRunSlug `
108130 - PriorHead $manifestPriorHead `
109131 - SkipShelfValidation
110132}
@@ -177,13 +199,12 @@ foreach ($policy in $requiredPolicies) {
177199
178200if (-not (Test-Path (Join-Path $fixture " .git" ))) {
179201 Push-Location $fixture
180- git init | Out-Null
181- git add README.md LICENSE SECURITY.md .gitignore
182- git - c user.email= " fixture@test" - c user.name= " fixture" commit - m " init minimal docs fixture" | Out-Null
202+ git - c " safe.directory= $fixture " init | Out-Null
203+ git - c " safe.directory= $fixture " add README.md LICENSE SECURITY.md .gitignore
204+ git - c " safe.directory= $fixture " - c user.email= " fixture@test" - c user.name= " fixture" commit - m " init minimal docs fixture" | Out-Null
183205 Pop-Location
184206}
185207
186- $fixtureSlug = " minimal-docs-repo"
187208$fixtureReport = Join-Path $Shelf " audits\$fixtureSlug \audit-report.md"
188209if (Test-Path $fixtureReport ) { Remove-Item $fixtureReport - Force }
189210
@@ -202,7 +223,6 @@ Assert-Pass "fixture audit-report scaffolded" {
202223}
203224
204225# Use a dedicated dry-run slug - never delete audits/github-optimization/ (real dogfood output).
205- $shelfDryRunSlug = " shelf-orchestrator-dry-run"
206226$shelfDryRunReport = Join-Path $Shelf " audits\$shelfDryRunSlug \audit-report.md"
207227if (Test-Path $shelfDryRunReport ) { Remove-Item $shelfDryRunReport - Force }
208228
@@ -220,6 +240,8 @@ Assert-Pass "shelf orchestrator dry-run report scaffolded" {
220240 }
221241}
222242
243+ Remove-GeneratedTestArtifacts
244+
223245Write-Output " "
224246if ($failures -eq 0 ) {
225247 Write-Output " regulation-tests: PASS"
0 commit comments