From c62fe096b12ad879b28775a5127d22012ea2eb46 Mon Sep 17 00:00:00 2001 From: Bert Date: Fri, 3 Nov 2023 22:24:14 +0100 Subject: [PATCH] use TargetFrameworks net6.0;net7.0 for tests (#1544) * update dependencies (System.Text.Json) * use net6.0;net7.0 for tests * do not use deprecated versions * update net SDK versions * remove unnecessary assert * execute coverlet.core tests only for net6.0 * add CheckNugetStatus.yml and fix findings * fix variable name * update and consolidate versions * upload *.diag.log files --- .gitignore | 2 + Directory.Build.props | 2 - Directory.Packages.props | 22 +++--- eng/CheckNugetStatus.yml | 69 +++++++++++++++++++ eng/azure-pipelines-nightly.yml | 8 +-- eng/azure-pipelines.yml | 5 ++ eng/build.yml | 31 +++++---- eng/publish-coverlet-result-files.yml | 14 ++-- src/coverlet.core/coverlet.core.csproj | 4 +- .../coverlet.msbuild.targets | 4 +- .../coverlet.collector.tests.csproj | 2 +- .../coverlet.core.tests.csproj | 8 ++- .../coverlet.integration.template.csproj | 4 +- test/coverlet.integration.tests/Msbuild.cs | 68 +++++++++++------- .../coverlet.integration.tests.csproj | 7 +- .../coverlet.msbuild.tasks.tests.csproj | 2 +- ...s.projectsample.excludedbyattribute.csproj | 2 +- 17 files changed, 180 insertions(+), 74 deletions(-) create mode 100644 eng/CheckNugetStatus.yml diff --git a/.gitignore b/.gitignore index 542fc1ea3..c606e1a82 100644 --- a/.gitignore +++ b/.gitignore @@ -307,3 +307,5 @@ test/coverlet.integration.determisticbuild/runsettings coverage.cobertura.xml coverage.opencover.xml +coverage.*.cobertura.xml +coverage.*.opencover.xml diff --git a/Directory.Build.props b/Directory.Build.props index d1d7af3fe..8657d18a4 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -45,8 +45,6 @@ 1.6.0 1.5.0 15.9.20 - 3.0.0 - 2.0.0 diff --git a/Directory.Packages.props b/Directory.Packages.props index 237ceaf00..304e11593 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -3,16 +3,14 @@ true true - - - - + + @@ -31,12 +29,12 @@ vstest 17.8 version NuGetFrameworksVersion is defined here https://github.com/microsoft/vstest/blob/9a0c41811637edf4afe0e265e08fdd1cb18109ed/eng/Versions.props#L94C1-L94C1 --> - + - + - + @@ -58,7 +56,13 @@ - + + + + + + + - + \ No newline at end of file diff --git a/eng/CheckNugetStatus.yml b/eng/CheckNugetStatus.yml new file mode 100644 index 000000000..036452e14 --- /dev/null +++ b/eng/CheckNugetStatus.yml @@ -0,0 +1,69 @@ +# File: CheckNugetStatus.yml +# the template will write lists of outdated, deprecated or vulnerable nuget packages to build log for every C# project. If a deprecated or vulnerable package is detected, an error will be written to the build log. +# Precondition: restore and build was executed before this template is used +# Limitation: dotnet SDK does not provide .NET framework MSBuild targets like "Microsoft.WebApplication.targets". This c# projects will be ignored and "An error occurred for " message is added in build log. + +parameters: + condition: 'succeeded()' + enableQualitySteps: true + sourcePath: '' + nugetConfig: '' + breakBuild: false + +steps: +- task: NuGetAuthenticate@0 + condition: ${{parameters.condition}} + enabled: ${{parameters.enableQualitySteps}} + +- task: PowerShell@2 + displayName: 'Check nuget package status' + inputs: + targetType: 'inline' + pwsh: true + script: | + Write-Information -MessageData "sourcePath='${{parameters.sourcePath}}'" -InformationAction Continue + Write-Information -MessageData "nugetConfig='${{parameters.nugetConfig}}'" -InformationAction Continue + Write-Information -MessageData "#########################################" -InformationAction Continue + if (!(Test-Path "${{parameters.sourcePath}}" -PathType Container)) { + Write-Host "##vso[task.LogIssue type=error;]sourcePath does not exist." + } + $existsDeprecatedPackage = $false + $existsVulnerablePackage = $false + + $projectFiles = Get-ChildItem -Path ${{parameters.sourcePath}} -Filter *.csproj -Recurse + foreach ($project in $projectFiles) { + try { + $outdatedList = dotnet list $project package --outdated --include-transitive --source https://api.nuget.org/v3/index.json + if ($LASTEXITCODE -gt 0) { + Throw "The command exited with error code: $lastexitcode" + } + $outdatedList + $deprecatedList = dotnet list $project package --deprecated --include-transitive --source https://api.nuget.org/v3/index.json + if ($deprecatedList.Length -gt 5) { + $deprecatedList + $existsDeprecatedPackage = $true + } else { + $deprecatedList[4] + } + $vulnerableList = dotnet list $project package --vulnerable --source https://api.nuget.org/v3/index.json + if ($vulnerableList.Length -gt 5) { + $vulnerableList + $existsVulnerablePackage = $true + } else { + $vulnerableList[4] + } + } catch { "An error occurred for $($project.PSChildName)" } + } + if ( $existsDeprecatedPackage -or $existsVulnerablePackage) { + Write-Host "##vso[task.LogIssue type=error;]Detected nuget package: Deprecated = $existsDeprecatedPackage, Vulnerable = $existsVulnerablePackage" + if ("${{parameters.breakBuild}}" -eq "true") { + exit 42 + } + } else { + Write-Information -MessageData "Did not detected deprecated or vulnerable nuget package." -InformationAction Continue + } + exit 0 + env: + SYSTEM_ACCESSTOKEN: $(System.AccessToken) + condition: ${{parameters.condition}} + enabled: ${{parameters.enableQualitySteps}} diff --git a/eng/azure-pipelines-nightly.yml b/eng/azure-pipelines-nightly.yml index 3daa3f7a8..951bef990 100644 --- a/eng/azure-pipelines-nightly.yml +++ b/eng/azure-pipelines-nightly.yml @@ -4,13 +4,13 @@ pool: steps: - task: UseDotNet@2 inputs: - version: 6.0.415 - displayName: Install .NET Core SDK 6.0.415 + version: 6.0.416 + displayName: Install .NET Core SDK 6.0.416 - task: UseDotNet@2 inputs: - version: 7.0.402 - displayName: Install .NET Core SDK 7.0.402 + version: 7.0.403 + displayName: Install .NET Core SDK 7.0.403 - task: NuGetAuthenticate@0 displayName: Authenticate with NuGet feeds diff --git a/eng/azure-pipelines.yml b/eng/azure-pipelines.yml index 113aea101..4c0119dae 100644 --- a/eng/azure-pipelines.yml +++ b/eng/azure-pipelines.yml @@ -37,6 +37,11 @@ jobs: ArtifactName: Packages publishLocation: Container condition: eq(variables['BuildConfiguration'], 'Release') + - template: CheckNugetStatus.yml + parameters: + sourcePath: '$(Build.SourcesDirectory)/src' + breakBuild: false + # nugetConfig: '$(Build.SourcesDirectory)/nuget.config' - job: macOS displayName: macOS diff --git a/eng/build.yml b/eng/build.yml index b9f9850b2..d1d20d456 100644 --- a/eng/build.yml +++ b/eng/build.yml @@ -1,13 +1,13 @@ steps: - task: UseDotNet@2 inputs: - version: 6.0.415 - displayName: Install .NET Core SDK 6.0.415 + version: 6.0.416 + displayName: Install .NET Core SDK 6.0.416 - task: UseDotNet@2 inputs: - version: 7.0.402 - displayName: Install .NET Core SDK 7.0.402 + version: 7.0.403 + displayName: Install .NET Core SDK 7.0.403 - script: dotnet restore displayName: Restore packages @@ -18,23 +18,26 @@ steps: - script: dotnet pack -c $(BuildConfiguration) --no-restore displayName: Pack -- task: DotNetCoreCLI@2 +- script: | + dotnet test test/coverlet.collector.tests/coverlet.collector.tests.csproj -c $(BuildConfiguration) --no-build -bl:test.collector.binlog --results-directory:"$(Build.SourcesDirectory)\artifacts\Reports" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[coverlet.core.tests.samples.netstandard]*%2c[coverlet.tests.xunit.extensions]*%2c[coverlet.tests.projectsample]*" --diag:"$(Build.SourcesDirectory)\artifacts\log\$(buildConfiguration)\coverlet.collector.test.diag.log;tracelevel=verbose" + dotnet test test/coverlet.core.tests/coverlet.core.tests.csproj -c $(BuildConfiguration) --no-build -bl:test.core.binlog --results-directory:"$(Build.SourcesDirectory)\artifacts\Reports" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[coverlet.core.tests.samples.netstandard]*%2c[coverlet.tests.xunit.extensions]*%2c[coverlet.tests.projectsample]*" --diag:"$(Build.SourcesDirectory)\artifacts\log\$(buildConfiguration)\coverlet.core.test.diag.log;tracelevel=verbose" + dotnet test test/coverlet.integration.tests/coverlet.integration.tests.csproj -c $(BuildConfiguration) --no-build -bl:test.integration.binlog --results-directory:"$(Build.SourcesDirectory)\artifacts\Reports" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[coverlet.core.tests.samples.netstandard]*%2c[coverlet.tests.xunit.extensions]*%2c[coverlet.tests.projectsample]*" --diag:"$(Build.SourcesDirectory)\artifacts\log\$(buildConfiguration)\coverlet.integration.test.diag.log;tracelevel=verbose" + dotnet test test/coverlet.msbuild.tasks.tests/coverlet.msbuild.tasks.tests.csproj -c $(BuildConfiguration) --no-build -bl:test.msbuild.binlog --results-directory:"$(Build.SourcesDirectory)\artifacts\Reports" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[coverlet.core.tests.samples.netstandard]*%2c[coverlet.tests.xunit.extensions]*%2c[coverlet.tests.projectsample]*" --diag:"$(Build.SourcesDirectory)\artifacts\log\$(buildConfiguration)\coverlet.msbuild.test.diag.log;tracelevel=verbose" displayName: Run tests with coverage + +- task: PublishTestResults@2 inputs: - command: test - projects: | - **/coverlet.collector.tests.csproj - **/coverlet.core.tests.csproj - **/coverlet.integration.tests.csproj - **/coverlet.msbuild.tasks.tests.csproj - arguments: -c $(BuildConfiguration) --no-build -bl:test.binlog /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[coverlet.core.tests.samples.netstandard]*%2c[coverlet.tests.xunit.extensions]*%2c[coverlet.tests.projectsample]*" --diag:"$(Build.SourcesDirectory)\artifacts\log\$(Configuration)\coverlet.test.diag.log;tracelevel=verbose" - testRunTitle: $(Agent.JobName) + testResultsFormat: 'VSTest' + testResultsFiles: '**/*.trx' + mergeTestResults: false + publishRunAttachments: true + - template: publish-coverlet-result-files.yml - template: publish-coverage-results.yml parameters: - reports: $(Build.SourcesDirectory)/**/coverage.opencover.xml + reports: $(Build.SourcesDirectory)/**/*.opencover.xml condition: and(succeeded(), eq(variables['BuildConfiguration'], 'Debug')) assemblyfilters: '-xunit;-coverlet.testsubject;-Coverlet.Tests.ProjectSample.*' classfilters: '-[coverlet.core.tests.samples.netstandard]*;-[coverlet.tests.xunit.extensions]*' diff --git a/eng/publish-coverlet-result-files.yml b/eng/publish-coverlet-result-files.yml index 11ae17485..60e502cd9 100644 --- a/eng/publish-coverlet-result-files.yml +++ b/eng/publish-coverlet-result-files.yml @@ -1,6 +1,6 @@ steps: - task: CopyFiles@2 - displayName: Copy tests results + displayName: Copy test results continueOnError: true condition: always() inputs: @@ -8,9 +8,9 @@ steps: Contents: | **/*.trx **/*.html - **/coverage.opencover.xml - **/coverage.cobertura.xml - **/coverage.json + **/*.opencover.xml + **/*.cobertura.xml + **/*.coverage.json **/log.txt **/log.datacollector.*.txt **/log.host.*.txt @@ -25,11 +25,13 @@ steps: TargetFolder: '$(Build.SourcesDirectory)/artifacts/TestLogs' - task: CopyFiles@2 - displayName: Copy binlog files + displayName: Copy log files condition: always() inputs: SourceFolder: '$(Build.SourcesDirectory)' - Contents: '**/*.binlog' + Contents: | + **/*.diag.log + **/*.binlog TargetFolder: '$(Build.SourcesDirectory)/artifacts/TestLogs/BuildLogs' - task: PublishPipelineArtifact@1 diff --git a/src/coverlet.core/coverlet.core.csproj b/src/coverlet.core/coverlet.core.csproj index dc7670b0b..15ce8a5d9 100644 --- a/src/coverlet.core/coverlet.core.csproj +++ b/src/coverlet.core/coverlet.core.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/src/coverlet.msbuild.tasks/coverlet.msbuild.targets b/src/coverlet.msbuild.tasks/coverlet.msbuild.targets index 6a12b2fc3..e8bbfac20 100644 --- a/src/coverlet.msbuild.tasks/coverlet.msbuild.targets +++ b/src/coverlet.msbuild.tasks/coverlet.msbuild.targets @@ -35,7 +35,7 @@ - + - + <_coverletMultiTargetFrameworksCurrentTFM Condition="'$(TargetFrameworks)' != ''" >$(TargetFramework) diff --git a/test/coverlet.collector.tests/coverlet.collector.tests.csproj b/test/coverlet.collector.tests/coverlet.collector.tests.csproj index 0a17b4b80..fdfa7d148 100644 --- a/test/coverlet.collector.tests/coverlet.collector.tests.csproj +++ b/test/coverlet.collector.tests/coverlet.collector.tests.csproj @@ -2,7 +2,7 @@ - net6.0 + net6.0;net7.0 false diff --git a/test/coverlet.core.tests/coverlet.core.tests.csproj b/test/coverlet.core.tests/coverlet.core.tests.csproj index c2dc9f8fa..988695d24 100644 --- a/test/coverlet.core.tests/coverlet.core.tests.csproj +++ b/test/coverlet.core.tests/coverlet.core.tests.csproj @@ -17,8 +17,8 @@ - - + + @@ -26,6 +26,10 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + + + + diff --git a/test/coverlet.integration.template/coverlet.integration.template.csproj b/test/coverlet.integration.template/coverlet.integration.template.csproj index 32b03ab45..c5d32aa32 100644 --- a/test/coverlet.integration.template/coverlet.integration.template.csproj +++ b/test/coverlet.integration.template/coverlet.integration.template.csproj @@ -11,8 +11,8 @@ - - + + diff --git a/test/coverlet.integration.tests/Msbuild.cs b/test/coverlet.integration.tests/Msbuild.cs index 96f533308..a02bfe728 100644 --- a/test/coverlet.integration.tests/Msbuild.cs +++ b/test/coverlet.integration.tests/Msbuild.cs @@ -1,6 +1,7 @@ // Copyright (c) Toni Solarin-Sodara // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System; using System.IO; using System.Linq; using Xunit; @@ -32,8 +33,8 @@ public void TestMsbuild() { using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject(); Assert.True(DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\"{clonedTemplateProject.ProjectRootPath}\"\\", out string standardOutput, out string standardError), standardOutput); - Assert.Contains("Passed!", standardOutput); - Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput); + Assert.Contains("Passed!", standardOutput, StringComparison.Ordinal); + Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput, StringComparison.Ordinal); Assert.True(File.Exists(Path.Combine(clonedTemplateProject.ProjectRootPath, "coverage.json"))); AssertCoverage(clonedTemplateProject); } @@ -43,8 +44,8 @@ public void TestMsbuild_NoCoverletOutput() { using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject(); Assert.True(DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true", out string standardOutput, out string standardError), standardOutput); - Assert.Contains("Passed!", standardOutput); - Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput); + Assert.Contains("Passed!", standardOutput, StringComparison.Ordinal); + Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput, StringComparison.Ordinal); Assert.True(File.Exists(Path.Combine(clonedTemplateProject.ProjectRootPath, "coverage.json"))); AssertCoverage(clonedTemplateProject); } @@ -54,8 +55,8 @@ public void TestMsbuild_CoverletOutput_Folder_FileNameWithoutExtension() { using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject(); Assert.True(DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\"{clonedTemplateProject.ProjectRootPath}\"\\file", out string standardOutput, out string standardError), standardOutput); - Assert.Contains("Passed!", standardOutput); - Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput); + Assert.Contains("Passed!", standardOutput, StringComparison.Ordinal); + Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput, StringComparison.Ordinal); Assert.True(File.Exists(Path.Combine(clonedTemplateProject.ProjectRootPath, "file.json"))); AssertCoverage(clonedTemplateProject, "file.json"); } @@ -65,8 +66,8 @@ public void TestMsbuild_CoverletOutput_Folder_FileNameExtension() { using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject(); Assert.True(DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\"{clonedTemplateProject.ProjectRootPath}\"\\file.ext", out string standardOutput, out string standardError), standardOutput); - Assert.Contains("Passed!", standardOutput); - Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput); + Assert.Contains("Passed!", standardOutput, StringComparison.Ordinal); + Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput, StringComparison.Ordinal); Assert.True(File.Exists(Path.Combine(clonedTemplateProject.ProjectRootPath, "file.ext"))); AssertCoverage(clonedTemplateProject, "file.ext"); } @@ -77,9 +78,17 @@ public void TestMsbuild_CoverletOutput_Folder_FileNameExtension_SpecifyFramework using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject(); Assert.False(clonedTemplateProject.IsMultipleTargetFramework()); string framework = clonedTemplateProject.GetTargetFrameworks().Single(); - Assert.True(DotnetCli($"test -c {_buildConfiguration} -f {framework} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\"{clonedTemplateProject.ProjectRootPath}\"\\file.ext", out string standardOutput, out string standardError), standardOutput); - Assert.Contains("Passed!", standardOutput); - Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput); + DotnetCli($"test -c {_buildConfiguration} -f {framework} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\"{clonedTemplateProject.ProjectRootPath}\"\\file.ext", out string standardOutput, out string standardError); + if (!string.IsNullOrEmpty(standardError)) + { + _output.WriteLine(standardError); + } + else + { + _output.WriteLine(standardOutput); + } + Assert.Contains("Passed!", standardOutput, StringComparison.Ordinal); + Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput, StringComparison.Ordinal); Assert.True(File.Exists(Path.Combine(clonedTemplateProject.ProjectRootPath, "file.ext"))); AssertCoverage(clonedTemplateProject, "file.ext"); } @@ -88,9 +97,16 @@ public void TestMsbuild_CoverletOutput_Folder_FileNameExtension_SpecifyFramework public void TestMsbuild_CoverletOutput_Folder_FileNameWithDoubleExtension() { using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject(); - Assert.True(DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\"{clonedTemplateProject.ProjectRootPath}\"\\file.ext1.ext2", out string standardOutput, out string standardError), standardOutput); - Assert.Contains("Passed!", standardOutput); - Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput); + DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\"{clonedTemplateProject.ProjectRootPath}\"\\file.ext1.ext2", out string standardOutput, out string standardError); + if (!string.IsNullOrEmpty(standardError)) + { + _output.WriteLine(standardError); + } else + { + _output.WriteLine(standardOutput); + } + Assert.Contains("Passed!", standardOutput, StringComparison.Ordinal); + Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput, StringComparison.Ordinal); Assert.True(File.Exists(Path.Combine(clonedTemplateProject.ProjectRootPath, "file.ext1.ext2"))); AssertCoverage(clonedTemplateProject, "file.ext1.ext2"); } @@ -102,8 +118,8 @@ public void Test_MultipleTargetFrameworkReport_NoCoverletOutput() string[] targetFrameworks = new string[] { "net6.0", "net7.0" }; UpdateProjectTargetFramework(clonedTemplateProject, targetFrameworks); Assert.True(DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true", out string standardOutput, out string standardError, clonedTemplateProject.ProjectRootPath!), standardOutput); - Assert.Contains("Passed!", standardOutput); - Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput); + Assert.Contains("Passed!", standardOutput, StringComparison.Ordinal); + Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput, StringComparison.Ordinal); foreach (string targetFramework in targetFrameworks) { @@ -125,8 +141,8 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder() _output.WriteLine(standardError); } Assert.True(result); - Assert.Contains("Passed!", standardOutput); - Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput); + Assert.Contains("Passed!", standardOutput, StringComparison.Ordinal); + Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput, StringComparison.Ordinal); foreach (string targetFramework in targetFrameworks) { @@ -144,8 +160,8 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWit string[] targetFrameworks = new string[] { "net6.0", "net7.0" }; UpdateProjectTargetFramework(clonedTemplateProject, targetFrameworks); Assert.True(DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\"{clonedTemplateProject.ProjectRootPath}\"\\file", out string standardOutput, out string standardError, clonedTemplateProject.ProjectRootPath!), standardOutput); - Assert.Contains("Passed!", standardOutput); - Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput); + Assert.Contains("Passed!", standardOutput, StringComparison.Ordinal); + Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput, StringComparison.Ordinal); foreach (string targetFramework in targetFrameworks) { @@ -166,8 +182,8 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWit Assert.Equal(2, frameworks.Length); string framework = frameworks.FirstOrDefault()!; Assert.True(DotnetCli($"test -c {_buildConfiguration} -f {framework} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\"{clonedTemplateProject.ProjectRootPath}\"\\file.ext", out string standardOutput, out string standardError, clonedTemplateProject.ProjectRootPath!), standardOutput); - Assert.Contains("Passed!", standardOutput); - Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput); + Assert.Contains("Passed!", standardOutput, StringComparison.Ordinal); + Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput, StringComparison.Ordinal); foreach (string targetFramework in targetFrameworks) { @@ -191,8 +207,8 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWit string[] targetFrameworks = new string[] { "net6.0", "net7.0" }; UpdateProjectTargetFramework(clonedTemplateProject, targetFrameworks); Assert.True(DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\"{clonedTemplateProject.ProjectRootPath}\"\\file.ext", out string standardOutput, out string standardError, clonedTemplateProject.ProjectRootPath!), standardOutput); - Assert.Contains("Passed!", standardOutput); - Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput); + Assert.Contains("Passed!", standardOutput, StringComparison.Ordinal); + Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput, StringComparison.Ordinal); foreach (string targetFramework in targetFrameworks) { @@ -209,8 +225,8 @@ public void Test_MultipleTargetFrameworkReport_CoverletOutput_Folder_FileNameWit string[] targetFrameworks = new string[] { "net6.0", "net7.0" }; UpdateProjectTargetFramework(clonedTemplateProject, targetFrameworks); Assert.True(DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" /p:CollectCoverage=true /p:Include=\"[{ClonedTemplateProject.AssemblyName}]*DeepThought\" /p:IncludeTestAssembly=true /p:CoverletOutput=\"{clonedTemplateProject.ProjectRootPath}\"\\file.ext1.ext2", out string standardOutput, out string standardError, clonedTemplateProject.ProjectRootPath!), standardOutput); - Assert.Contains("Passed!", standardOutput); - Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput); + Assert.Contains("Passed!", standardOutput, StringComparison.Ordinal); + Assert.Contains("| coverletsamplelib.integration.template | 100% | 100% | 100% |", standardOutput, StringComparison.Ordinal); foreach (string targetFramework in targetFrameworks) { diff --git a/test/coverlet.integration.tests/coverlet.integration.tests.csproj b/test/coverlet.integration.tests/coverlet.integration.tests.csproj index 97a6c7f78..c318f8910 100644 --- a/test/coverlet.integration.tests/coverlet.integration.tests.csproj +++ b/test/coverlet.integration.tests/coverlet.integration.tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net6.0;net7.0 false enable false @@ -9,11 +9,14 @@ - + + + + diff --git a/test/coverlet.msbuild.tasks.tests/coverlet.msbuild.tasks.tests.csproj b/test/coverlet.msbuild.tasks.tests/coverlet.msbuild.tasks.tests.csproj index 1fb12cd89..69208be7e 100644 --- a/test/coverlet.msbuild.tasks.tests/coverlet.msbuild.tasks.tests.csproj +++ b/test/coverlet.msbuild.tasks.tests/coverlet.msbuild.tasks.tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net6.0;net7.0 enable enable true diff --git a/test/coverlet.tests.projectsample.excludedbyattribute/coverlet.tests.projectsample.excludedbyattribute.csproj b/test/coverlet.tests.projectsample.excludedbyattribute/coverlet.tests.projectsample.excludedbyattribute.csproj index 3020bf383..f85ac3dc8 100644 --- a/test/coverlet.tests.projectsample.excludedbyattribute/coverlet.tests.projectsample.excludedbyattribute.csproj +++ b/test/coverlet.tests.projectsample.excludedbyattribute/coverlet.tests.projectsample.excludedbyattribute.csproj @@ -1,7 +1,7 @@ - net6.0 + net6.0;net7.0 false false