Skip to content

Commit

Permalink
Bump sdk and move .NET tool to LTS (coverlet-coverage#1022)
Browse files Browse the repository at this point in the history
Bump sdk and move .NET tool to LTS
  • Loading branch information
MarcoRossignoli authored Dec 27, 2020
1 parent fcb2ec0 commit bc58ae0
Show file tree
Hide file tree
Showing 19 changed files with 75 additions and 75 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="3.0.28" PrivateAssets="all" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.3.37" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="all" />
</ItemGroup>
</Project>
8 changes: 4 additions & 4 deletions eng/azure-pipelines-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ pool:
steps:
- task: UseDotNet@2
inputs:
version: 2.2.402
displayName: Install .NET Core SDK 2.2.402
version: 3.1.404
displayName: Install .NET Core SDK 3.1.404

- task: UseDotNet@2
inputs:
version: 3.1.401
displayName: Install .NET Core SDK 3.1.401
version: 5.0.101
displayName: Install .NET Core SDK 5.0.101

- task: NuGetAuthenticate@0
displayName: Authenticate with NuGet feeds
Expand Down
6 changes: 3 additions & 3 deletions eng/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ trigger:
jobs:
- job: Windows
displayName: Windows
continueOnError: true
continueOnError: 'true'
strategy:
matrix:
Debug:
Expand Down Expand Up @@ -37,7 +37,7 @@ jobs:

- job: macOS
displayName: macOS
continueOnError: true
continueOnError: 'true'
strategy:
matrix:
Debug:
Expand All @@ -51,7 +51,7 @@ jobs:

- job: Linux
displayName: Linux
continueOnError: true
continueOnError: 'true'
strategy:
matrix:
Debug:
Expand Down
8 changes: 4 additions & 4 deletions eng/build.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
steps:
- task: UseDotNet@2
inputs:
version: 2.2.402
displayName: Install .NET Core SDK 2.2.402
version: 3.1.404
displayName: Install .NET Core SDK 3.1.404

- task: UseDotNet@2
inputs:
version: 3.1.401
displayName: Install .NET Core SDK 3.1.401
version: 5.0.101
displayName: Install .NET Core SDK 5.0.101

- script: dotnet restore
displayName: Restore packages
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "3.1.401"
"version": "5.0.101"
}
}
2 changes: 1 addition & 1 deletion src/coverlet.console/coverlet.console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<ToolCommandName>coverlet</ToolCommandName>
<PackAsTool>true</PackAsTool>
<AssemblyTitle>coverlet.console</AssemblyTitle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="$(RepoRoot)src\coverlet.msbuild.tasks\coverlet.msbuild.props" />

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="$(RepoRoot)src\coverlet.msbuild.tasks\coverlet.msbuild.props" />

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
6 changes: 3 additions & 3 deletions test/coverlet.core.tests/coverlet.core.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="$(RepoRoot)src\coverlet.msbuild.tasks\coverlet.msbuild.props" />

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);CS8002</NoWarn>
<!--For test TestInstrument_NetstandardAwareAssemblyResolver_PreserveCompilationContext-->
Expand Down Expand Up @@ -54,8 +54,8 @@
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Condition="$([MSBuild]::IsOSPlatform('Windows'))" Command="copy $(ProjectDir)..\coverlet.tests.projectsample.excludedbyattribute\$(OutDir) $(TargetDir)TestAssets /Y" />
<Exec Condition="$([MSBuild]::IsOSPlatform('OSX')) OR $([MSBuild]::IsOSPlatform('Linux'))" Command="cp -r $(ProjectDir)..\coverlet.tests.projectsample.excludedbyattribute\$(OutDir). $(TargetDir)TestAssets" />
<Exec Condition="$([MSBuild]::IsOSPlatform('Windows'))" Command="copy $(RepoRoot)test\coverlet.tests.projectsample.excludedbyattribute\$(OutDir) $(TargetDir)TestAssets /Y" />
<Exec Condition="$([MSBuild]::IsOSPlatform('OSX')) OR $([MSBuild]::IsOSPlatform('Linux'))" Command="cp -r $(RepoRoot)test/coverlet.tests.projectsample.excludedbyattribute/$(OutDir). $(TargetDir)TestAssets" />
</Target>

<Import Project="$(RepoRoot)src\coverlet.msbuild.tasks\coverlet.msbuild.targets" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Import Project="$(MSBuildThisFileDirectory)\DeterministicTest.props" />

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
<AssemblyName>coverletsample.integration.determisticbuild</AssemblyName>
<RestoreSources>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
<AssemblyName>coverletsamplelib.integration.template</AssemblyName>
<IsTestProject>false</IsTestProject>
Expand Down
38 changes: 19 additions & 19 deletions test/coverlet.integration.tests/BaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private protected bool RunCommand(string command, string arguments, out string s
psi.WorkingDirectory = workingDirectory;
psi.RedirectStandardError = true;
psi.RedirectStandardOutput = true;
Process commandProcess = Process.Start(psi);
Process commandProcess = Process.Start(psi)!;
if (!commandProcess.WaitForExit((int)TimeSpan.FromMinutes(5).TotalMilliseconds))
{
throw new XunitException($"Command 'dotnet {arguments}' didn't end after 5 minute");
Expand Down Expand Up @@ -114,8 +114,8 @@ private protected void UpdateNugeConfigtWithLocalPackageFolder(string projectPat
}

string localPackageFolder = Path.GetFullPath($"../../../../../bin/{GetAssemblyBuildConfiguration()}/Packages");
xml.Element("configuration")
.Element("packageSources")
xml.Element("configuration")!
.Element("packageSources")!
.Elements()
.ElementAt(0)
.AddAfterSelf(new XElement("add", new XAttribute("key", "localCoverletPackages"), new XAttribute("value", localPackageFolder)));
Expand All @@ -135,9 +135,9 @@ private void SetIsTestProjectTrue(string projectPath)
xml = XDocument.Load(csprojStream);
}

xml.Element("Project")
.Element("PropertyGroup")
.Element("IsTestProject").Value = "true";
xml.Element("Project")!
.Element("PropertyGroup")!
.Element("IsTestProject")!.Value = "true";

xml.Save(csproj);
}
Expand All @@ -155,8 +155,8 @@ private protected void AddMicrosoftNETTestSdkRef(string projectPath, string vers
xml = XDocument.Load(csprojStream);
}

xml.Element("Project")
.Element("ItemGroup")
xml.Element("Project")!
.Element("ItemGroup")!
.Add(new XElement("PackageReference", new XAttribute("Include", "Microsoft.NET.Test.Sdk"),
new XAttribute("Version", version)));
xml.Save(csproj);
Expand All @@ -175,8 +175,8 @@ private protected void AddCoverletMsbuildRef(string projectPath)
xml = XDocument.Load(csprojStream);
}
string msbuildPkgVersion = GetPackageVersion("*msbuild*.nupkg");
xml.Element("Project")
.Element("ItemGroup")
xml.Element("Project")!
.Element("ItemGroup")!
.Add(new XElement("PackageReference", new XAttribute("Include", "coverlet.msbuild"), new XAttribute("Version", msbuildPkgVersion)));
xml.Save(csproj);
}
Expand All @@ -194,8 +194,8 @@ private protected void AddCoverletCollectosRef(string projectPath)
xml = XDocument.Load(csprojStream);
}
string msbuildPkgVersion = GetPackageVersion("*collector*.nupkg");
xml.Element("Project")
.Element("ItemGroup")
xml.Element("Project")!
.Element("ItemGroup")!
.Add(new XElement("PackageReference", new XAttribute("Include", "coverlet.collector"), new XAttribute("Version", msbuildPkgVersion)));
xml.Save(csproj);
}
Expand Down Expand Up @@ -261,9 +261,9 @@ private protected void UpdateProjectTargetFramework(ClonedTemplateProject projec
xml = XDocument.Load(csprojStream);
}

xml.Element("Project")
.Element("PropertyGroup")
.Element("TargetFramework")
xml.Element("Project")!
.Element("PropertyGroup")!
.Element("TargetFramework")!
.Remove();

XElement targetFrameworkElement;
Expand All @@ -277,7 +277,7 @@ private protected void UpdateProjectTargetFramework(ClonedTemplateProject projec
targetFrameworkElement = new XElement("TargetFrameworks", string.Join(';', targetFrameworks));
}

xml.Element("Project").Element("PropertyGroup").Add(targetFrameworkElement);
xml.Element("Project")!.Element("PropertyGroup")!.Add(targetFrameworkElement);
xml.Save(project.ProjectFileNamePath);
}

Expand Down Expand Up @@ -328,14 +328,14 @@ public bool IsMultipleTargetFramework()
{
using var csprojStream = File.OpenRead(ProjectFileNamePath);
XDocument xml = XDocument.Load(csprojStream);
return xml.Element("Project").Element("PropertyGroup").Element("TargetFramework") == null;
return xml.Element("Project")!.Element("PropertyGroup")!.Element("TargetFramework") == null;
}

public string[] GetTargetFrameworks()
{
using var csprojStream = File.OpenRead(ProjectFileNamePath);
XDocument xml = XDocument.Load(csprojStream);
XElement element = xml.Element("Project").Element("PropertyGroup").Element("TargetFramework") ?? xml.Element("Project").Element("PropertyGroup").Element("TargetFrameworks");
XElement element = xml.Element("Project")!.Element("PropertyGroup")!.Element("TargetFramework") ?? xml.Element("Project")!.Element("PropertyGroup")!.Element("TargetFrameworks")!;
if (element is null)
{
throw new ArgumentNullException("No 'TargetFramework' neither 'TargetFrameworks' found in csproj file");
Expand All @@ -354,7 +354,7 @@ public void Dispose()
{
try
{
Directory.Delete(ProjectRootPath, true);
// Directory.Delete(ProjectRootPath, true);
}
catch (UnauthorizedAccessException)
{
Expand Down
8 changes: 4 additions & 4 deletions test/coverlet.integration.tests/Collectors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void TestVsTest_Test()
Assert.True(DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" --collect:\"XPlat Code Coverage\" --diag:{Path.Combine(clonedTemplateProject.ProjectRootPath, "log.txt")}", out string standardOutput, out string standardError, clonedTemplateProject.ProjectRootPath!), standardOutput);
// We don't have any result to check because tests and code to instrument are in same assembly so we need to pass
// IncludeTestAssembly=true we do it in other test
Assert.Contains("Test Run Successful.", standardOutput);
Assert.Contains("Passed!", standardOutput);
AssertCollectorsInjection(clonedTemplateProject);
}

Expand All @@ -88,7 +88,7 @@ public void TestVsTest_Test_Settings()
using ClonedTemplateProject clonedTemplateProject = PrepareTemplateProject();
string runSettingsPath = AddCollectorRunsettingsFile(clonedTemplateProject.ProjectRootPath!);
Assert.True(DotnetCli($"test -c {_buildConfiguration} \"{clonedTemplateProject.ProjectRootPath}\" --collect:\"XPlat Code Coverage\" --settings \"{runSettingsPath}\" --diag:{Path.Combine(clonedTemplateProject.ProjectRootPath, "log.txt")}", out string standardOutput, out string standardError), standardOutput);
Assert.Contains("Test Run Successful.", standardOutput);
Assert.Contains("Passed!", standardOutput);
AssertCoverage(clonedTemplateProject);
AssertCollectorsInjection(clonedTemplateProject);
}
Expand All @@ -104,7 +104,7 @@ public void TestVsTest_VsTest()
Assert.True(DotnetCli($"vstest \"{publishedTestFile}\" --collect:\"XPlat Code Coverage\" --diag:{Path.Combine(clonedTemplateProject.ProjectRootPath, "log.txt")}", out standardOutput, out standardError), standardOutput);
// We don't have any result to check because tests and code to instrument are in same assembly so we need to pass
// IncludeTestAssembly=true we do it in other test
Assert.Contains("Test Run Successful.", standardOutput);
Assert.Contains("Passed!", standardOutput);
AssertCollectorsInjection(clonedTemplateProject);
}

Expand All @@ -117,7 +117,7 @@ public void TestVsTest_VsTest_Settings()
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => f.Contains("publish"));
Assert.NotNull(publishedTestFile);
Assert.True(DotnetCli($"vstest \"{publishedTestFile}\" --collect:\"XPlat Code Coverage\" --ResultsDirectory:\"{clonedTemplateProject.ProjectRootPath}\" /settings:\"{runSettingsPath}\" --diag:{Path.Combine(clonedTemplateProject.ProjectRootPath, "log.txt")}", out standardOutput, out standardError), standardOutput);
Assert.Contains("Test Run Successful.", standardOutput);
Assert.Contains("Passed!", standardOutput);
AssertCoverage(clonedTemplateProject);
AssertCollectorsInjection(clonedTemplateProject);
}
Expand Down
12 changes: 6 additions & 6 deletions test/coverlet.integration.tests/DeterministicBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ private void CreateDeterministicTestPropsFile()
new XElement("PropertyGroup",
new XElement("coverletMsbuilVersion", GetPackageVersion("*msbuild*.nupkg")),
new XElement("coverletCollectorsVersion", GetPackageVersion("*collector*.nupkg")))));
_testProjectTfm = XElement.Load(Path.Combine(_testProjectPath, "coverlet.integration.determisticbuild.csproj")).
Descendants("PropertyGroup").Single().Element("TargetFramework").Value;
_testProjectTfm = XElement.Load(Path.Combine(_testProjectPath, "coverlet.integration.determisticbuild.csproj"))!.
Descendants("PropertyGroup")!.Single().Element("TargetFramework")!.Value;

deterministicTestProps.Save(Path.Combine(_testProjectPath, PropsFileName));
}
Expand Down Expand Up @@ -69,7 +69,7 @@ public void Msbuild()
Assert.Contains("=/_/", File.ReadAllText(sourceRootMappingFilePath));

DotnetCli($"test -c {_buildConfiguration} --no-build /p:CollectCoverage=true /p:Include=\"[coverletsample.integration.determisticbuild]*DeepThought\" /p:IncludeTestAssembly=true", out standardOutput, out _, _testProjectPath);
Assert.Contains("Test Run Successful.", standardOutput);
Assert.Contains("Passed!", standardOutput);
Assert.Contains("| coverletsample.integration.determisticbuild | 100% | 100% | 100% |", standardOutput);
Assert.True(File.Exists(Path.Combine(_testProjectPath, "coverage.json")));
AssertCoverage(standardOutput);
Expand All @@ -92,7 +92,7 @@ public void Msbuild_SourceLink()
Assert.Contains("=/_/", File.ReadAllText(sourceRootMappingFilePath));

DotnetCli($"test -c {_buildConfiguration} --no-build /p:CollectCoverage=true /p:UseSourceLink=true /p:Include=\"[coverletsample.integration.determisticbuild]*DeepThought\" /p:IncludeTestAssembly=true", out standardOutput, out _, _testProjectPath);
Assert.Contains("Test Run Successful.", standardOutput);
Assert.Contains("Passed!", standardOutput);
Assert.Contains("| coverletsample.integration.determisticbuild | 100% | 100% | 100% |", standardOutput);
Assert.True(File.Exists(Path.Combine(_testProjectPath, "coverage.json")));
Assert.Contains("raw.githubusercontent.com", File.ReadAllText(Path.Combine(_testProjectPath, "coverage.json")));
Expand All @@ -117,7 +117,7 @@ public void Collectors()

string runSettingsPath = AddCollectorRunsettingsFile(_testProjectPath, "[coverletsample.integration.determisticbuild]*DeepThought");
Assert.True(DotnetCli($"test -c {_buildConfiguration} --no-build \"{_testProjectPath}\" --collect:\"XPlat Code Coverage\" --settings \"{runSettingsPath}\" --diag:{Path.Combine(_testProjectPath, "log.txt")}", out standardOutput, out _), standardOutput);
Assert.Contains("Test Run Successful.", standardOutput);
Assert.Contains("Passed!", standardOutput);
AssertCoverage(standardOutput);

// Check out/in process collectors injection
Expand Down Expand Up @@ -145,7 +145,7 @@ public void Collectors_SourceLink()

string runSettingsPath = AddCollectorRunsettingsFile(_testProjectPath, "[coverletsample.integration.determisticbuild]*DeepThought", sourceLink: true);
Assert.True(DotnetCli($"test -c {_buildConfiguration} --no-build \"{_testProjectPath}\" --collect:\"XPlat Code Coverage\" --settings \"{runSettingsPath}\" --diag:{Path.Combine(_testProjectPath, "log.txt")}", out standardOutput, out _), standardOutput);
Assert.Contains("Test Run Successful.", standardOutput);
Assert.Contains("Passed!", standardOutput);
AssertCoverage(standardOutput);
Assert.Contains("raw.githubusercontent.com", File.ReadAllText(Directory.GetFiles(_testProjectPath, "coverage.cobertura.xml", SearchOption.AllDirectories).Single()));

Expand Down
6 changes: 3 additions & 3 deletions test/coverlet.integration.tests/DotnetTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public void DotnetTool()
UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!);
string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!);
DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj"));
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
RunCommand(coverletToolCommandPath, $"\"{publishedTestFile}\" --target \"dotnet\" --targetargs \"test {Path.Combine(clonedTemplateProject.ProjectRootPath, ClonedTemplateProject.ProjectFileName)} --no-build\" --include-test-assembly --output \"{clonedTemplateProject.ProjectRootPath}\"\\", out standardOutput, out standardError);
Assert.Contains("Test Run Successful.", standardOutput);
Assert.Contains("Passed!", standardOutput);
AssertCoverage(clonedTemplateProject, standardOutput: standardOutput);
}

Expand All @@ -39,7 +39,7 @@ public void StandAlone()
UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!);
string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!);
DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj"));
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --output \"{clonedTemplateProject.ProjectRootPath}\"\\", out standardOutput, out standardError);
Assert.Contains("Hello World!", standardOutput);
AssertCoverage(clonedTemplateProject, standardOutput: standardOutput);
Expand Down
Loading

0 comments on commit bc58ae0

Please sign in to comment.