@@ -26,6 +26,10 @@ function Repair-PullRequestTest {
26
26
from the development branch to the current branch, without running Update-PesterTest
27
27
or committing any changes.
28
28
29
+ . PARAMETER Pattern
30
+ Pattern to filter test files. Only files matching this pattern will be processed.
31
+ Supports wildcards (e.g., "*Login*" to match files containing "Login").
32
+
29
33
. NOTES
30
34
Tags: Testing, Pester, PullRequest, CI
31
35
Author: dbatools team
@@ -53,7 +57,8 @@ function Repair-PullRequestTest {
53
57
[switch ]$AutoCommit ,
54
58
[int ]$MaxPRs = 5 ,
55
59
[int ]$BuildNumber ,
56
- [switch ]$CopyOnly
60
+ [switch ]$CopyOnly ,
61
+ [string ]$Pattern
57
62
)
58
63
59
64
begin {
@@ -269,7 +274,14 @@ function Repair-PullRequestTest {
269
274
$fileErrorPath = @ ()
270
275
$testdirectory = Join-Path $script :ModulePath " tests"
271
276
272
- foreach ($test in $allFailedTestsAcrossPRs ) {
277
+ # Apply Pattern filter first if specified
278
+ $filteredTests = if ($Pattern ) {
279
+ $allFailedTestsAcrossPRs | Where-Object { [System.IO.Path ]::GetFileName($_.TestFile ) -match $Pattern }
280
+ } else {
281
+ $allFailedTestsAcrossPRs
282
+ }
283
+
284
+ foreach ($test in $filteredTests ) {
273
285
$fileName = [System.IO.Path ]::GetFileName($test.TestFile )
274
286
# ONLY include files that are actually in the PR changes
275
287
if ($allRelevantTestFiles.Count -eq 0 -or $fileName -in $allRelevantTestFiles ) {
@@ -284,7 +296,11 @@ function Repair-PullRequestTest {
284
296
}
285
297
}
286
298
$fileErrorPath = $fileErrorPath | Sort-Object - Unique
287
- Write-Verbose " Found failures in $ ( $fileErrorMap.Keys.Count ) unique test files (filtered to PR changes only)"
299
+ $filterMessage = " filtered to PR changes only"
300
+ if ($Pattern ) {
301
+ $filterMessage += " and pattern '$Pattern '"
302
+ }
303
+ Write-Verbose " Found failures in $ ( $fileErrorMap.Keys.Count ) unique test files ($filterMessage )"
288
304
foreach ($fileName in $fileErrorMap.Keys ) {
289
305
Write-Verbose " ${fileName} - $ ( $fileErrorMap [$fileName ].Count) failures"
290
306
Write-Verbose " Paths: $fileErrorPath "
0 commit comments