Skip to content

Commit 99c2bea

Browse files
Jos KoelewijnJos Koelewijn
Jos Koelewijn
authored and
Jos Koelewijn
committed
Add RuleToTest parameter to Test-ScriptAnalyzer to aid with test driven rule development
1 parent 83394d6 commit 99c2bea

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

build.psm1

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,14 @@ function Start-ScriptAnalyzerBuild
289289
function Test-ScriptAnalyzer
290290
{
291291
[CmdletBinding()]
292-
param ( [Parameter()][switch]$InProcess, [switch]$ShowAll )
292+
param (
293+
[Parameter()]
294+
[switch]$InProcess,
295+
296+
[switch]$ShowAll,
297+
298+
[string]$RuleToTest
299+
)
293300

294301
END {
295302
# versions 3 and 4 don't understand versioned module paths, so we need to rename the directory of the version to
@@ -319,7 +326,12 @@ function Test-ScriptAnalyzer
319326
$testModulePath = Join-Path "${projectRoot}" -ChildPath out
320327
}
321328
$testResultsFile = "'$(Join-Path ${projectRoot} -childPath TestResults.xml)'"
322-
$testScripts = "'${projectRoot}\Tests\Engine','${projectRoot}\Tests\Rules','${projectRoot}\Tests\Documentation'"
329+
if ($RuleToTest) {
330+
$testScripts = Get-Childitem -Path "${projectRoot}\Tests\Rules" -Filter *$RuleToTest*.tests.ps1 | Select-Object -ExpandProperty FullName
331+
}
332+
else {
333+
$testScripts = "'${projectRoot}\Tests\Engine','${projectRoot}\Tests\Rules','${projectRoot}\Tests\Documentation'"
334+
}
323335
try {
324336
if ( $major -lt 5 ) {
325337
Rename-Item $script:destinationDir ${testModulePath}

0 commit comments

Comments
 (0)