@@ -265,7 +265,10 @@ function Repair-PullRequestTest {
265
265
Write-Verbose " All relevant test files across PRs - $ ( $allRelevantTestFiles -join ' , ' ) "
266
266
267
267
# Create hash table to group ALL errors by unique file name
268
- $fileErrorMap = @ {}
268
+ $fileErrorMap = @ {}
269
+ $fileErrorPath = @ ()
270
+ $testdirectory = Join-Path $script :ModulePath " tests"
271
+
269
272
foreach ($test in $allFailedTestsAcrossPRs ) {
270
273
$fileName = [System.IO.Path ]::GetFileName($test.TestFile )
271
274
# ONLY include files that are actually in the PR changes
@@ -274,12 +277,17 @@ function Repair-PullRequestTest {
274
277
$fileErrorMap [$fileName ] = @ ()
275
278
}
276
279
$fileErrorMap [$fileName ] += $test
280
+
281
+ if ($test.TestFile ) {
282
+ $fileErrorPath += (Join-Path $testdirectory $test.TestFile )
283
+ }
277
284
}
278
285
}
279
-
286
+ $fileErrorPath = $fileErrorPath | Sort-Object - Unique
280
287
Write-Verbose " Found failures in $ ( $fileErrorMap.Keys.Count ) unique test files (filtered to PR changes only)"
281
288
foreach ($fileName in $fileErrorMap.Keys ) {
282
289
Write-Verbose " ${fileName} - $ ( $fileErrorMap [$fileName ].Count) failures"
290
+ Write-Verbose " Paths: $fileErrorPath "
283
291
}
284
292
285
293
# If no relevant failures after filtering, exit
@@ -524,9 +532,6 @@ function Repair-PullRequestTest {
524
532
Write-Verbose " All $ ( $updateJobs.Count ) Update-PesterTest parallel jobs completed"
525
533
Write-Progress - Activity " Running Update-PesterTest (Parallel)" - Completed - Id 1
526
534
527
- # Collect successfully processed files and run formatter
528
- Get-ChildItem $jobInfo.TestPath | Invoke-DbatoolsFormatter
529
-
530
535
# Commit changes if requested
531
536
if ($AutoCommit ) {
532
537
Write-Progress - Activity " Repairing Pull Request Tests" - Status " Committing fixes..." - PercentComplete 90 - Id 0
@@ -539,6 +544,11 @@ function Repair-PullRequestTest {
539
544
}
540
545
}
541
546
547
+ # Collect successfully processed files and run formatter
548
+ if ($fileErrorPath ) {
549
+ $null = Get-ChildItem $fileErrorPath - File | Invoke-DbatoolsFormatter
550
+ }
551
+
542
552
# Complete the overall progress
543
553
Write-Progress - Activity " Repairing Pull Request Tests" - Status " Completed processing $ ( $processedFiles.Keys.Count ) unique test files" - PercentComplete 100 - Id 0
544
554
Write-Progress - Activity " Repairing Pull Request Tests" - Completed - Id 0
0 commit comments