1
1
[CmdletBinding ()]
2
2
param (
3
-
3
+
4
+ [Parameter (ParameterSetName = ' Build' )]
4
5
[ValidateSet (' PSV3 Debug' , ' PSV3 Release' , ' Debug' , ' Release' )]
5
6
[string ] $Configuration = ' Debug' ,
6
7
8
+ [Parameter (ParameterSetName = ' Build' )]
7
9
[switch ] $BuildSolution = $false ,
8
10
11
+ [Parameter (ParameterSetName = ' Build' )]
9
12
[switch ] $CleanSolution = $false ,
10
13
14
+ [Parameter (ParameterSetName = ' Build' )]
11
15
[switch ] $BuildDocs = $false ,
12
16
17
+ [Parameter (ParameterSetName = ' Build' )]
13
18
[switch ] $CleanOutput = $false ,
14
19
20
+ [Parameter (ParameterSetName = ' Build' )]
15
21
[switch ] $Install = $false ,
16
22
23
+ [Parameter (ParameterSetName = ' Build' )]
17
24
[switch ] $Uninstall = $false ,
18
25
26
+ [Parameter (ParameterSetName = ' Test' )]
19
27
[switch ] $Test = $false ,
20
28
29
+ [Parameter (ParameterSetName = ' Test' )]
21
30
[switch ] $Engine = $false ,
22
31
23
- [switch ] $Rules = $false
32
+ [Parameter (ParameterSetName = ' Test' )]
33
+ [switch ] $Rules = $false ,
34
+
35
+ [Parameter (ParameterSetName = ' Test' )]
36
+ [switch ] $RunInDifferentProcess = $false
24
37
)
25
38
26
39
# Some cmdlets like copy-item do not respond to the $verbosepreference variable
@@ -118,7 +131,7 @@ if ($Test)
118
131
Import-Module PSScriptAnalyzer - ErrorAction Stop
119
132
Import-Module - Name Pester - RequiredVersion 3.4 .0 - ErrorAction Stop
120
133
121
-
134
+
122
135
Function GetTestRunnerScriptContent ($testPath )
123
136
{
124
137
$x = @"
@@ -127,7 +140,7 @@ if ($Test)
127
140
"@
128
141
return $x
129
142
}
130
-
143
+
131
144
Function CreateTestRunnerScript ($testPath )
132
145
{
133
146
$tmptmpFilePath = [System.IO.Path ]::GetTempFileName()
@@ -150,17 +163,18 @@ if ($Test)
150
163
}
151
164
return $testPath
152
165
}
153
-
154
- Function RunTest ($TestType , $DifferentProcess )
166
+
167
+ Function RunTest ($TestType , [ Boolean ] $DifferentProcess )
155
168
{
156
- $testPath = GetTestPath($TestType )
169
+ $testPath = GetTestPath($TestType )
157
170
if ($DifferentProcess )
158
171
{
159
172
$testScriptFilePath = CreateTestRunnerScript $testPath
160
173
Start-Process powershell - ArgumentList " -NoExit" , " -File $testScriptFilePath " - Verb runas
174
+ # clean up the test file
161
175
}
162
176
else
163
- {
177
+ {
164
178
try
165
179
{
166
180
Push-Location .
@@ -169,24 +183,22 @@ if ($Test)
169
183
finally
170
184
{
171
185
Pop-Location
186
+
172
187
}
173
188
}
174
- # clean up the test file
175
189
}
176
190
177
- if ($Engine )
191
+ if ($Engine -or ( -not ( $Engine -or $Rules )) )
178
192
{
179
- RunTest( ' engine' )
193
+ RunTest ' engine' $RunInDifferentProcess
180
194
}
181
- if ($Rules )
195
+ if ($Rules -or ( -not ( $Engine -or $Rules )) )
182
196
{
183
- RunTest( ' rules' )
197
+ RunTest ' rules' $RunInDifferentProcess
184
198
}
185
199
}
186
200
187
201
if ($Uninstall )
188
202
{
189
203
Remove-Item - Path $modulePSSAPath - Force - Verbose:$verbosity - Recurse
190
- }
191
-
192
-
204
+ }
0 commit comments