Skip to content

Commit 25dc8c6

Browse files
authored
Fix the issue that core tests are not included when TestsToRun equals to All (#27273)
1 parent e626f7d commit 25dc8c6

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

tools/BuildScripts/BuildModules.ps1

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111
# See the License for the specific language governing permissions and
1212
# limitations under the License.
1313
# ----------------------------------------------------------------------------------
14-
[CmdletBinding(DefaultParameterSetName="AllSet")]
14+
[CmdletBinding(DefaultParameterSetName = "AllSet")]
1515
param (
1616
[string]$RepoRoot,
1717
[string]$Configuration = 'Debug',
18-
[Parameter(ParameterSetName="AllSet")]
18+
[Parameter(ParameterSetName = "AllSet")]
1919
[string]$TestsToRun = 'All',
20-
[Parameter(ParameterSetName="CIPlanSet", Mandatory=$true)]
20+
[Parameter(ParameterSetName = "CIPlanSet", Mandatory = $true)]
2121
[switch]$CIPlan,
22-
[Parameter(ParameterSetName="ModifiedModuleSet", Mandatory=$true)]
22+
[Parameter(ParameterSetName = "ModifiedModuleSet", Mandatory = $true)]
2323
[switch]$ModifiedModule,
24-
[Parameter(ParameterSetName="TargetModuleSet", Mandatory=$true)]
24+
[Parameter(ParameterSetName = "TargetModuleSet", Mandatory = $true)]
2525
[string[]]$TargetModule,
2626
[switch]$ForceRegenerate,
2727
[switch]$InvokedByPipeline,
@@ -51,7 +51,8 @@ Import-Module $BuildScriptsModulePath
5151

5252
if (-not (Test-Path $sourceDirectory)) {
5353
Write-Warning "Cannot find source directory: $sourceDirectory"
54-
} elseif (-not (Test-Path $generatedDirectory)) {
54+
}
55+
elseif (-not (Test-Path $generatedDirectory)) {
5556
Write-Warning "Cannot find generated directory: $generatedDirectory"
5657
}
5758

@@ -72,20 +73,22 @@ switch ($PSCmdlet.ParameterSetName) {
7273
}
7374
if ('Core' -eq $TestsToRun) {
7475
$testModule = $coreTestModule
75-
} elseif ('NonCore') {
76-
$testModule = $TargetModule | Where-Object { $_ -notin $coreTestModule}
77-
} else {
76+
}
77+
elseif ('NonCore' -eq $TestsToRun) {
78+
$testModule = $TargetModule | Where-Object { $_ -notin $coreTestModule }
79+
}
80+
else {
7881
$testModule = $TargetModule
7982
}
8083
}
8184
'CIPlanSet' {
8285
$CIPlanPath = Join-Path $RepoArtifacts "PipelineResult" "CIPlan.json"
8386
If (Test-Path $CIPlanPath) {
8487
$CIPlanContent = Get-Content $CIPlanPath | ConvertFrom-Json
85-
foreach($build in $CIPlanContent.build) {
88+
foreach ($build in $CIPlanContent.build) {
8689
$TargetModule += $build
8790
}
88-
foreach($test in $CIPlanContent.test) {
91+
foreach ($test in $CIPlanContent.test) {
8992
$testModule += $test
9093
}
9194
}
@@ -100,7 +103,8 @@ switch ($PSCmdlet.ParameterSetName) {
100103
if ($line -match "^##\s\d+\.\d+\.\d+") {
101104
if ($continueReading) {
102105
break
103-
} else {
106+
}
107+
else {
104108
$continueReading = $true
105109
}
106110
}
@@ -110,11 +114,11 @@ switch ($PSCmdlet.ParameterSetName) {
110114
}
111115
}
112116
$testModule = $TargetModule
113-
Write-Host "----------Start building modified modules----------`r`n$($TargetModule | Join-String -Separator "`r`n")" -ForegroundColor DarkYellow
117+
Write-Host "----------Start building modified modules----------`r`n$($TargetModule | Join-String -Separator "`r`n")" -ForegroundColor DarkYellow
114118
}
115119
'TargetModuleSet' {
116120
$testModule = $TargetModule
117-
Write-Host "----------Start building target modules----------`r`n$($TargetModule | Join-String -Separator "`r`n")" -ForegroundColor DarkYellow
121+
Write-Host "----------Start building target modules----------`r`n$($TargetModule | Join-String -Separator "`r`n")" -ForegroundColor DarkYellow
118122
}
119123
}
120124

@@ -155,7 +159,8 @@ Write-Output "Modules are added to build sln file"
155159
$LogFile = Join-Path $RepoArtifacts 'Build.log'
156160
if ('Release' -eq $Configuration) {
157161
$BuildAction = 'publish'
158-
} else {
162+
}
163+
else {
159164
$BuildAction = 'build'
160165

161166
$testCsprojFiles = Get-CsprojFromModule -TestModuleList $testModule -RepoRoot $RepoRoot -Configuration $Configuration
@@ -171,12 +176,10 @@ if ('Release' -eq $Configuration) {
171176
}
172177

173178
$buildCmdResult = "dotnet $BuildAction $Buildsln -c $Configuration -fl '/flp1:logFile=$LogFile;verbosity=quiet'"
174-
If ($GenerateDocumentationFile -eq "false")
175-
{
179+
If ($GenerateDocumentationFile -eq "false") {
176180
$buildCmdResult += " -p:GenerateDocumentationFile=false"
177181
}
178-
if ($EnableTestCoverage -eq "true")
179-
{
182+
if ($EnableTestCoverage -eq "true") {
180183
$buildCmdResult += " -p:TestCoverage=TESTCOVERAGE"
181184
}
182185
Invoke-Expression -Command $buildCmdResult
@@ -188,4 +191,4 @@ $removeScriptPath = Join-Path $toolDirectory 'BuildScripts' 'RemoveUnwantedFiles
188191
& $removeScriptPath -RootPath (Join-Path $RepoArtifacts $Configuration) -CodeSign $CodeSign
189192

190193
$updateModuleScriptPath = Join-Path $toolDirectory 'UpdateModules.ps1'
191-
pwsh $updateModuleScriptPath -BuildConfig $Configuration -Scope $Scope
194+
pwsh $updateModuleScriptPath -BuildConfig $Configuration -Scope $Scope

0 commit comments

Comments
 (0)