Skip to content

Commit 2c0c047

Browse files
authored
Updated test coverage yaml file due to .NET version upgrade (#22242)
1 parent d5a74c0 commit 2c0c047

File tree

2 files changed

+49
-26
lines changed

2 files changed

+49
-26
lines changed

.azure-pipelines/test-coverage.yml

Lines changed: 47 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
parameters:
2-
- name: poolName
3-
displayName: Pool Name
4-
type: string
5-
default: pool-windows-2019
62
- name: dotnet_sdk_3_1
73
displayName: .NET Core 3.1
84
default: 3.1.x
@@ -18,6 +14,14 @@ parameters:
1814
displayName: Test Framework
1915
type: string
2016
default: netcoreapp3.1
17+
- name: testPoolName
18+
displayName: Test Pool Name
19+
type: string
20+
default: pool-windows-2019
21+
- name: testPoolVMImage
22+
displayName: Test Pool VM Image
23+
type: string
24+
default: ' '
2125

2226
variables:
2327
EnableTestCoverage: true
@@ -27,10 +31,36 @@ pr: none
2731
trigger: none
2832

2933
jobs:
34+
- job: Build
35+
displayName: Build
36+
pool: pool-windows-2019
37+
38+
steps:
39+
- task: UseDotNet@2
40+
displayName: 'Install .NET 6 SDK'
41+
inputs:
42+
packageType: sdk
43+
version: ${{ parameters.dotnet_sdk_6 }}
44+
45+
- task: DotNetCoreCLI@2
46+
displayName: Build Azure PowerShell Modules
47+
inputs:
48+
command: custom
49+
custom: msbuild
50+
arguments: 'build.proj -t:"Clean;Build" -p:"Configuration=Debug"'
51+
52+
- task: PublishPipelineArtifact@1
53+
displayName: Publish Build Artifacts
54+
inputs:
55+
targetPath: artifacts
56+
artifact: BuildArtifacts
57+
3058
- job: TestCoverage
59+
dependsOn: Build
3160
timeoutInMinutes: 600
3261
pool:
33-
name: ${{ parameters.poolName }}
62+
name: ${{ parameters.testPoolName }}
63+
vmImage: ${{ parameters.testPoolVMImage }}
3464

3565
steps:
3666
- task: UseDotNet@2
@@ -46,12 +76,11 @@ jobs:
4676
targetType: filePath
4777
filePath: ./tools/TestFx/Utilities/CommonUtility.ps1
4878

49-
- task: DotNetCoreCLI@2
50-
displayName: Build Azure PowerShell Solution
79+
- task: DownloadPipelineArtifact@2
80+
displayName: Download pipeline artifacts
5181
inputs:
52-
command: custom
53-
custom: msbuild
54-
arguments: 'build.proj -t:"Clean;Build" -p:"Configuration=Debug"'
82+
targetPath: artifacts
83+
artifactName: BuildArtifacts
5584

5685
- task: DotNetCoreCLI@2
5786
displayName: Test SDK-Based Cmdlets
@@ -66,25 +95,18 @@ jobs:
6695
condition: succeeded()
6796
inputs:
6897
pwsh: true
69-
workingDirectory: 'artifacts/Debug'
7098
targetType: inline
7199
script: |
72100
Install-Module -Name Pester -RequiredVersion 4.10.1 -Force
73-
Import-Module (Join-Path -Path . -ChildPath Az.Accounts | Join-Path -ChildPath Az.Accounts.psd1) -Force
74-
75-
$PreErrorActionPreference = $ErrorActionPreference
76-
$ErrorActionPreference = "SilentlyContinue"
77-
78-
Get-ChildItem -Path . -Filter test-module.ps1 -File -Recurse | ForEach-Object {
79-
try {
80-
. $_ -Isolated
81-
}
82-
catch {
83-
Write-Host $_.Exception
84-
}
85-
}
86101
87-
$ErrorActionPreference = $PreErrorActionPreference
102+
if ($IsWindows) { $delimiter = ";" } else { $delimiter = ":" }
103+
$rootDir = (Get-Location).Path
104+
$debugDir = Join-Path -Path $rootDir -ChildPath "artifacts" | Join-Path -ChildPath "Debug"
105+
$env:PSModulePath += $delimiter + $debugDir
106+
Get-ChildItem -Path $debugDir -Filter test-module.ps1 -File -Recurse | Select-Object -ExpandProperty FullName | ForEach-Object {
107+
Write-Host "##[section]Testing $_"
108+
& $_
109+
}
88110
89111
- task: PowerShell@2
90112
displayName: Analyze Test Coverage

tools/TestFx/Coverage/SaveTestCoverageResult.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ if (Test-Path -LiteralPath $cvgDir -PathType Container) {
4949
@{ Name = "LineNumber"; Expression = { $_.LineNumber } }, `
5050
@{ Name = "StartDateTime"; Expression = { $_.StartDateTime } }, `
5151
@{ Name = "EndDateTime"; Expression = { $_.EndDateTime } }, `
52-
@{ Name = "IsSuccess"; Expression = { $_.IsSuccess } } |
52+
@{ Name = "IsSuccess"; Expression = { $_.IsSuccess } }, `
53+
@{ Name = "ExtendedProperties"; Expression = { $null } } |
5354
Export-Csv -Path $_ -Encoding utf8 -NoTypeInformation -Force
5455
}
5556

0 commit comments

Comments
 (0)