Skip to content

Add .NET 5 test target #1891

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

Merged
merged 10 commits into from
Jul 3, 2021
Merged
Show file tree
Hide file tree
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
5 changes: 1 addition & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,5 @@
<PackageOutputPath>$(MSBuildThisFileDirectory)bin\Packages\$(Configuration)\</PackageOutputPath>
<DefineConstants Condition=" '$(ExtraDefine)' != '' ">$(DefineConstants);$(ExtraDefine)</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>

</Project>
5 changes: 3 additions & 2 deletions LibGit2Sharp.Tests/BlobFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Text;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
using Xunit.Extensions;

namespace LibGit2Sharp.Tests
{
Expand Down Expand Up @@ -44,6 +43,7 @@ public void CanGetBlobAsFilteredText(string autocrlf, string expectedText)
}
}

#if NETFRAMEWORK || NETCOREAPP2_1
[Theory]
[InlineData("ascii", 4, "31 32 33 34")]
[InlineData("utf-7", 4, "31 32 33 34")]
Expand Down Expand Up @@ -83,6 +83,7 @@ public void CanGetBlobAsTextWithVariousEncodings(string encodingName, int expect
Assert.Equal(expectedUtf7Chars, string.Join(" ", utf7Chars));
}
}
#endif

[Fact]
public void CanGetBlobSize()
Expand Down Expand Up @@ -185,7 +186,7 @@ public void CanStageAFileGeneratedFromABlobContentStream()
var sb = new StringBuilder();
for (int j = 0; j < 2000; j++)
{
sb.Append(((i + 1)*(j + 1)).ToString("X8"));
sb.Append(((i + 1) * (j + 1)).ToString("X8"));
}
File.AppendAllText(Path.Combine(repo.Info.WorkingDirectory, "small.txt"), sb.ToString());
}
Expand Down
17 changes: 8 additions & 9 deletions LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net472;netcoreapp2.1;net5.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\LibGit2Sharp\LibGit2Sharp.csproj" />
<ProjectReference Include="..\NativeLibraryLoadTestApp\x86\NativeLibraryLoadTestApp.x86.csproj" Condition="'$(TargetFramework)' != 'netcoreapp2.1'" ReferenceOutputAssembly="false" OutputItemType="TestAppExe" />
<ProjectReference Include="..\NativeLibraryLoadTestApp\x64\NativeLibraryLoadTestApp.x64.csproj" Condition="'$(TargetFramework)' != 'netcoreapp2.1'" ReferenceOutputAssembly="false" OutputItemType="TestAppExe" />
<ProjectReference Include="..\NativeLibraryLoadTestApp\x86\NativeLibraryLoadTestApp.x86.csproj" Condition="'$(TargetFramework)' == 'net472'" ReferenceOutputAssembly="false" OutputItemType="TestAppExe" />
<ProjectReference Include="..\NativeLibraryLoadTestApp\x64\NativeLibraryLoadTestApp.x64.csproj" Condition="'$(TargetFramework)' == 'net472'" ReferenceOutputAssembly="false" OutputItemType="TestAppExe" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="Moq" Version="4.10.1" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.console" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="xunit.skippablefact" Version="1.3.12" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
<PackageReference Include="xunit.skippablefact" Version="1.4.13" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\LibGit2Sharp\Core\Platform.cs" Link="TestHelpers\Platform.cs" />
<Compile Remove="desktop\**" Condition="'$(TargetFramework)' == 'netcoreapp2.1'" />
<Compile Remove="desktop\**" Condition="'$(TargetFramework)' != 'net472'" />
<Content Include="Resources\**\*.*" CopyToOutputDirectory="PreserveNewest" />
<None Update="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
Expand Down
11 changes: 7 additions & 4 deletions LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using LibGit2Sharp.Core;
using Xunit;

namespace LibGit2Sharp.Tests.TestHelpers
Expand All @@ -21,7 +20,7 @@ public BaseFixture()
BuildFakeConfigs(this);

#if LEAKS_IDENTIFYING
LeaksContainer.Clear();
Core.LeaksContainer.Clear();
#endif
}

Expand Down Expand Up @@ -65,7 +64,11 @@ private static void SetUpTestEnvironment()

if (resourcesPath == null)
{
#if NETFRAMEWORK
resourcesPath = Path.Combine(Directory.GetParent(new Uri(typeof(BaseFixture).GetTypeInfo().Assembly.CodeBase).LocalPath).FullName, "Resources");
#else
resourcesPath = Path.Combine(Directory.GetParent(typeof(BaseFixture).GetTypeInfo().Assembly.Location).FullName, "Resources");
#endif
}

ResourcesDirectory = new DirectoryInfo(resourcesPath);
Expand Down Expand Up @@ -273,11 +276,11 @@ public virtual void Dispose()
GC.Collect();
GC.WaitForPendingFinalizers();

if (LeaksContainer.TypeNames.Any())
if (Core.LeaksContainer.TypeNames.Any())
{
Assert.False(true, string.Format("Some handles of the following types haven't been properly released: {0}.{1}"
+ "In order to get some help fixing those leaks, uncomment the define LEAKS_TRACKING in Libgit2Object.cs{1}"
+ "and run the tests locally.", string.Join(", ", LeaksContainer.TypeNames), Environment.NewLine));
+ "and run the tests locally.", string.Join(", ", Core.LeaksContainer.TypeNames), Environment.NewLine));
}
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp/LibGit2Sharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<ItemGroup>
<PackageReference Include="LibGit2Sharp.NativeBinaries" Version="[2.0.312]" PrivateAssets="none" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="all" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.0.50" PrivateAssets="all" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.4.220" PrivateAssets="all" />
</ItemGroup>

<Import Project="..\Targets\CodeGenerator.targets" />
Expand Down
23 changes: 7 additions & 16 deletions azure-pipelines/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,6 @@ steps:
- script: dotnet pack --no-build -c $(BuildConfiguration) /v:m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/pack.binlog"
displayName: dotnet pack

- task: DotNetCoreCLI@2
displayName: dotnet test -f net46 (w/ coverage)
inputs:
command: test
arguments: --no-build -c $(BuildConfiguration) -f net46 --filter "TestCategory!=FailsInCloudTest & TestCategory!=FailsWhileInstrumented" -v n /p:CollectCoverage=true
testRunTitle: net46-$(Agent.JobName)
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))

- task: DotNetCoreCLI@2
displayName: dotnet test -f net46 (w/o coverage)
inputs:
command: test
arguments: --no-build -c $(BuildConfiguration) -f net46 --filter "TestCategory!=FailsInCloudTest & TestCategory=FailsWhileInstrumented" -v n
testRunTitle: net46-$(Agent.JobName)-nocoverage
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))

- task: DotNetCoreCLI@2
displayName: dotnet test -f net472 (w/ coverage)
inputs:
Expand All @@ -45,6 +29,13 @@ steps:
arguments: --no-build -c $(BuildConfiguration) -f netcoreapp2.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true
testRunTitle: netcoreapp2.1-$(Agent.JobName)

- task: DotNetCoreCLI@2
displayName: dotnet test -f net5.0
inputs:
command: test
arguments: --no-build -c $(BuildConfiguration) -f net5.0 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true
testRunTitle: net5.0-$(Agent.JobName)

- task: PowerShell@2
inputs:
filePath: azure-pipelines/artifacts/_pipelines.ps1
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.201"
"version": "5.0.301"
}
}