Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestFramework: Fix coverage #8581

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ variables:
- name: UnitTestProjectPath
value: 'analyzers\tests\SonarAnalyzer.Test\'
- name: UnitTestResultsPath
value: '$(Agent.TempDirectory)\TestResults'
value: '$(Build.SourcesDirectory)\TestResults'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated deconfusion, to use the same directory before and after the artifact is restored

- name: CoveragePath
value: '$(Agent.TempDirectory)\coverage'
value: '$(Build.SourcesDirectory)\coverage'
- name: UnitTestExclusionsPattern
value: 'analyzers/tests/SonarAnalyzer.Test/TestCases/**/*'
- name: isReleaseBranch
Expand Down Expand Up @@ -222,25 +222,25 @@ stages:
strategy:
matrix:
Net48:
FrameworkMoniker: 'net48'
CoverageArtifactName: 'DotnetCoverageNet48'
TestResultsArtifactName: 'DotnetTestResultsNet48'
CoverageArtifactName: 'DotNetCoverageNet48'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reordered by priority

TestResultsArtifactName: 'DotNetTestResultsNet48'
ProjectFilePath: 'tests\SonarAnalyzer.Test\SonarAnalyzer.Test.csproj'
FrameworkMoniker: 'net48'
Net70:
FrameworkMoniker: 'net7.0-windows'
CoverageArtifactName: 'DotnetCoverageNet7'
TestResultsArtifactName: 'DotnetTestResultsNet7'
CoverageArtifactName: 'DotNetCoverageNet7'
TestResultsArtifactName: 'DotNetTestResultsNet7'
ProjectFilePath: 'tests\SonarAnalyzer.Test\SonarAnalyzer.Test.csproj'
FrameworkMoniker: 'net7.0-windows'
Net80:
FrameworkMoniker: 'net8.0-windows'
CoverageArtifactName: 'DotnetCoverageNet8'
TestResultsArtifactName: 'DotnetTestResultsNet8'
CoverageArtifactName: 'DotNetCoverageNet8'
TestResultsArtifactName: 'DotNetTestResultsNet8'
ProjectFilePath: 'tests\SonarAnalyzer.Net8.Test\SonarAnalyzer.Net8.Test.csproj'
FrameworkMoniker: 'net8.0-windows'
TestFramework:
FrameworkMoniker: 'net7.0-windows'
CoverageArtifactName: 'DotnetCoverageTestFramework'
TestResultsArtifactName: 'DotnetTestResultsTestFramework'
CoverageArtifactName: 'DotNetCoverageTestFramework'
TestResultsArtifactName: 'DotNetTestResultsTestFramework'
ProjectFilePath: 'tests\SonarAnalyzer.TestFramework.Test\SonarAnalyzer.TestFramework.Test.csproj'
FrameworkMoniker: 'net7.0-windows'

steps:
- task: DownloadPipelineArtifact@2
Expand All @@ -251,7 +251,7 @@ stages:

- powershell: |
cd analyzers
& dotnet test $(ProjectFilePath) -f $(FrameworkMoniker) -c $(BuildConfiguration) -l trx --results-directory $(UnitTestResultsPath) /p:AltCover=true,AltCoverForce=true,AltCoverVisibleBranches=true,AltCoverAssemblyFilter='Moq|Humanizer|AltCover|Microsoft.VisualStudio.TestPlatform.*|.*Test',AltCoverPathFilter='SonarAnalyzer\.CFG\\ShimLayer|SonarAnalyzer\.ShimLayer\.CodeGeneration',AltCoverAttributeFilter='ExcludeFromCodeCoverage',AltCoverReport=$(CoveragePath)/coverage.$(FrameworkMoniker).xml
& dotnet test $(ProjectFilePath) -f $(FrameworkMoniker) -c $(BuildConfiguration) -l trx --results-directory $(UnitTestResultsPath) /p:AltCover=true,AltCoverForce=true,AltCoverVisibleBranches=true,AltCoverAssemblyFilter="Moq|Humanizer|AltCover|Microsoft.VisualStudio.TestPlatform.*|\.Test^",AltCoverPathFilter="SonarAnalyzer\.CFG\\ShimLayer|SonarAnalyzer\.ShimLayer\.CodeGeneration",AltCoverAttributeFilter="ExcludeFromCodeCoverage",AltCoverReport="$(CoveragePath)/coverage.$(CoverageArtifactName).xml"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the actual fix, .*Test was matching the .TestFramework part

displayName: '.Net UTs'

- task: PublishPipelineArtifact@1
Expand Down Expand Up @@ -302,8 +302,8 @@ stages:
projectVersion: '$(SONAR_PROJECT_VERSION)'
extraProperties: |
sonar.verbose=true
sonar.cs.opencover.reportsPaths="$(Build.SourcesDirectory)/coverage/**.xml"
sonar.cs.vstest.reportsPaths="$(Build.SourcesDirectory)/TestResults/*.trx"
sonar.cs.opencover.reportsPaths="$(CoveragePath)/*.xml"
sonar.cs.vstest.reportsPaths="$(UnitTestResultsPath)/*.trx"
sonar.test.exclusions="$(UnitTestExclusionsPattern)"
sonar.analysis.buildNumber=$(Build.BuildId)
sonar.analysis.pipeline=$(Build.BuildId)
Expand All @@ -323,8 +323,8 @@ stages:
projectVersion: '$(SONAR_PROJECT_VERSION)'
extraProperties: |
sonar.verbose=true
sonar.cs.opencover.reportsPaths="$(Build.SourcesDirectory)/coverage/**.xml"
sonar.cs.vstest.reportsPaths="$(Build.SourcesDirectory)/TestResults/*.trx"
sonar.cs.opencover.reportsPaths="$(CoveragePath)/*.xml"
sonar.cs.vstest.reportsPaths="$(UnitTestResultsPath)/*.trx"
sonar.test.exclusions="$(UnitTestExclusionsPattern)"
sonar.analysis.buildNumber=$(Build.BuildId)
sonar.analysis.pipeline=$(Build.BuildId)
Expand Down Expand Up @@ -356,49 +356,49 @@ stages:
- task: DownloadPipelineArtifact@2
displayName: 'Download coverage reports'
inputs:
artifact: DotnetCoverageNet48
artifact: DotNetCoverageNet48
targetPath: 'coverage'

- task: DownloadPipelineArtifact@2
displayName: 'Download coverage reports'
inputs:
artifact: DotnetCoverageNet7
artifact: DotNetCoverageNet7
targetPath: 'coverage'

- task: DownloadPipelineArtifact@2
displayName: 'Download coverage reports'
inputs:
artifact: DotnetCoverageNet8
artifact: DotNetCoverageNet8
targetPath: 'coverage'

- task: DownloadPipelineArtifact@2
displayName: 'Download coverage reports'
inputs:
artifact: DotnetCoverageTestFramework
artifact: DotNetCoverageTestFramework
targetPath: 'coverage'

- task: DownloadPipelineArtifact@2
displayName: 'Download test results'
inputs:
artifact: DotnetTestResultsNet48
artifact: DotNetTestResultsNet48
targetPath: 'TestResults'

- task: DownloadPipelineArtifact@2
displayName: 'Download test results'
inputs:
artifact: DotnetTestResultsNet7
artifact: DotNetTestResultsNet7
targetPath: 'TestResults'

- task: DownloadPipelineArtifact@2
displayName: 'Download test results'
inputs:
artifact: DotnetTestResultsNet8
artifact: DotNetTestResultsNet8
targetPath: 'TestResults'

- task: DownloadPipelineArtifact@2
displayName: 'Download test results'
inputs:
artifact: DotnetTestResultsTestFramework
artifact: DotNetTestResultsTestFramework
targetPath: 'TestResults'

- powershell: |
Expand Down