Skip to content
This repository was archived by the owner on Jan 6, 2021. It is now read-only.
Closed
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
17 changes: 6 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
language: csharp
mono: latest
dotnet: 1.0.4
mono: none
dotnet: 2.1.300
dist: trusty

solution: src/GitTools.Testing.sln
sudo: false
install:
- nuget install xunit.runner.console -Version 2.1.0 -OutputDirectory ./src/packages

script:
- dotnet restore src/GitTools.Testing.sln
- msbuild ./src/GitTools.Testing.sln /property:Configuration=Debug
- dotnet test ./src/GitTools.Testing.Tests/GitTools.Testing.Tests.csproj --configuration Debug --no-build --framework netcoreapp1.0
# Disable testing against .NET 4.5.2 through Mono because it tries to resolve
# the Windows libgit binary instead of the linux one.
# - mono --debug --runtime=v4.0.30319 ./src/packages/xunit.runner.console.2.1.0/tools/xunit.console.exe ./src/GitTools.Testing.Tests/bin/Debug/net452/GitTools.Testing.Tests.dll
- dotnet build ./src/GitTools.Testing.sln --configuration Debug
- cd ./src/GitTools.Testing.Tests
- dotnet xunit -configuration Debug -nobuild --fx-version 2.1.0
5 changes: 3 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ environment:
install:
- choco install gitversion.portable -pre -y

image: Visual Studio 2017 Preview
image: Visual Studio 2017

configuration:
- Release

Expand All @@ -25,7 +26,7 @@ after_build:
test: off
test_script:
- cmd: cd src\GitTools.Testing.Tests
- cmd: dotnet test --configuration Release --no-build
- cmd: dotnet xunit -configuration Release -nobuild --fx-version 2.1.0

deploy:
provider: NuGet
Expand Down
106 changes: 8 additions & 98 deletions src/GitTools.Testing.Tests/Example.cs
Original file line number Diff line number Diff line change
@@ -1,112 +1,22 @@
using Xunit;
using Xunit.Abstractions;

namespace GitTools.Testing.Tests
{
using System;
#if NET452
using System.Runtime.Remoting.Messaging;
#endif
using JetBrains.Annotations;
using Logging;

public class Example
{
private readonly ITestOutputHelper _outputHelper;
public Example(ITestOutputHelper outputHelper) { _outputHelper = outputHelper; }

[Fact]
public void TheReadmeSample()
{
#if NET452
using (LogHelper.Capture(_outputHelper, LogProvider.SetCurrentLogProvider))
{
#endif
using (var fixture = new EmptyRepositoryFixture())
{
fixture.MakeACommit();
fixture.MakeACommit();
fixture.MakeATaggedCommit("1.0.0");
fixture.BranchTo("develop");
fixture.MakeACommit();
fixture.Checkout("master");
fixture.MergeNoFF("develop");
}
#if NET452
}
#endif
}
}

#if NET452
public static class LogHelper
{
private static readonly XUnitProvider Provider;

static LogHelper()
{
Provider = new XUnitProvider();
}

public static IDisposable Capture(ITestOutputHelper outputHelper, Action<ILogProvider> setProvider)
{
// TODO Only do this once
setProvider(Provider);

CallContext.SetData("CurrentOutputHelper", outputHelper);

return new DelegateDisposable(() =>
{
CallContext.SetData("CurrentOutputHelper", null);
});
}

class DelegateDisposable : IDisposable
{
private readonly Action _action;

public DelegateDisposable(Action action)
using (var fixture = new EmptyRepositoryFixture())
{
_action = action;
fixture.MakeACommit();
fixture.MakeACommit();
fixture.MakeATaggedCommit("1.0.0");
fixture.BranchTo("develop");
fixture.MakeACommit();
fixture.Checkout("master");
fixture.MergeNoFF("develop");
}

public void Dispose()
{
_action();
}
}
}

public class XUnitProvider : ILogProvider
{
public Logger GetLogger(string name)
{
return XUnitLogger;
}

private bool XUnitLogger(LogLevel logLevel, [CanBeNull] Func<string> messageFunc, [CanBeNull] Exception exception, params object[] formatParameters)
{
if (messageFunc == null) return true;
var currentHelper = (ITestOutputHelper)CallContext.GetData("CurrentOutputHelper");
if (currentHelper == null)
return false;

currentHelper.WriteLine("[{0}] {1}", logLevel, messageFunc());
if (exception != null)
currentHelper.WriteLine("Exception:{0}{1}", Environment.NewLine, exception.ToString());

return true;
}

public IDisposable OpenNestedContext(string message)
{
throw new NotImplementedException();
}

public IDisposable OpenMappedContext(string key, string value)
{
throw new NotImplementedException();
}
}
#endif
}
15 changes: 5 additions & 10 deletions src/GitTools.Testing.Tests/GitTools.Testing.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">Any CPU</Platform>
<OutputType>Library</OutputType>
<TargetFrameworks>net452;netcoreapp1.0</TargetFrameworks>
<TargetFramework>netcoreapp2.0</TargetFramework>
<OutputPath>bin\$(Configuration)\</OutputPath>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
Expand Down Expand Up @@ -33,18 +33,13 @@
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="LibGit2Sharp" Version="0.25.0-preview-0033" />
<PackageReference Include="LibGit2Sharp" Version="0.25.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="15.3.0" />
<PackageReference Include="xunit" Version="2.3.0-beta4-build3742" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.0-beta4-build3742" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp1.0'">
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0-beta4-build3742" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net452'">
<!--<PackageReference Include="xunit.runner.console" Version="2.3.0-beta4-build3742" />-->
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GitTools.Testing\GitTools.Testing.csproj" />
</ItemGroup>
Expand Down
5 changes: 4 additions & 1 deletion src/GitTools.Testing.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".configs", ".configs", "{EB
ProjectSection(SolutionItems) = preProject
..\.travis.yml = ..\.travis.yml
..\appveyor.yml = ..\appveyor.yml
..\GitVersionConfig.yaml = ..\GitVersionConfig.yaml
..\GitVersion.yml = ..\GitVersion.yml
..\README.md = ..\README.md
EndProjectSection
EndProject
Expand All @@ -33,4 +33,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B5BD4730-E58A-46CD-A37E-47884080BE88}
EndGlobalSection
EndGlobal
10 changes: 3 additions & 7 deletions src/GitTools.Testing/GitTools.Testing.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net452;netstandard1.3</TargetFrameworks>
<TargetFramework>netstandard2.0</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<OutputPath>bin\$(Configuration)\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard1.3'">
<DefineConstants>$(DefineConstants);LIBLOG_PORTABLE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Expand All @@ -16,9 +14,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.3.0" />
<PackageReference Include="LibGit2Sharp" Version="0.25.0-preview-0033" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.3'">
<PackageReference Include="LibGit2Sharp" Version="0.25.2" />
<PackageReference Include="System.Diagnostics.TraceSource" Version="4.3.0" />
</ItemGroup>
</ItemGroup>
</Project>