Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,4 @@ Thumbs.db
# Folder config file
Desktop.ini

_NCrunch_GitVersion
118 changes: 118 additions & 0 deletions AcceptanceTests/AcceptanceTests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{BF905F84-382C-440D-92F5-C61108626D8D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AcceptanceTests</RootNamespace>
<AssemblyName>AcceptanceTests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="ApprovalTests">
<HintPath>..\packages\ApprovalTests.3.0.5\lib\net40\ApprovalTests.dll</HintPath>
</Reference>
<Reference Include="ApprovalUtilities">
<HintPath>..\packages\ApprovalUtilities.3.0.5\lib\net35\ApprovalUtilities.dll</HintPath>
</Reference>
<Reference Include="LibGit2Sharp">
<HintPath>..\packages\LibGit2Sharp.0.16.0.0\lib\net35\LibGit2Sharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="TestStack.BDDfy, Version=3.19.1.0, Culture=neutral, PublicKeyToken=a357057d05a879bd, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\TestStack.BDDfy.3.19.1\lib\NET40\TestStack.BDDfy.dll</HintPath>
</Reference>
<Reference Include="xunit">
<HintPath>..\packages\xunit.1.9.2\lib\net20\xunit.dll</HintPath>
</Reference>
<Reference Include="xunit.extensions">
<HintPath>..\packages\xunit.extensions.1.9.2\lib\net20\xunit.extensions.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="EmptyRepositorySpecification.cs" />
<Compile Include="ExecArgSpecification.cs" />
<Compile Include="Helpers\ExecutionResults.cs" />
<Compile Include="Helpers\GitHelper.cs" />
<Compile Include="Helpers\GitVersionHelper.cs" />
<Compile Include="Helpers\PathHelper.cs" />
<Compile Include="Helpers\ProcessHelper.cs" />
<Compile Include="Helpers\Scrubbers.cs" />
<Compile Include="NoTagsInRepositorySpecification.cs" />
<Compile Include="NoTagsInRepositoryWithNextVersionTxtSpecification.cs" />
<Compile Include="ProjArgSpecification.cs" />
<Compile Include="Properties\ApprovalTestsConfig.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="PullRequestsFixture.cs" />
<Compile Include="RepositoryFixture.cs" />
<Compile Include="TagFollowedByCommitsWithApplicableNextVersionTxtSpecification.cs" />
<Compile Include="TagFollowedByCommitsWithNoNextVersionTxtSpecification.cs" />
<Compile Include="TagFollowedByCommitsWithRedundantNextVersionTxtSpecification.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="TestBuildFile.proj" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GitVersion\GitVersion.csproj">
<Project>{c3578a7b-09a6-4444-9383-0deafa4958bd}</Project>
<Name>GitVersion</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
if not exist "$(TargetDir)NativeBinaries" md "$(TargetDir)NativeBinaries"
if not exist "$(TargetDir)NativeBinaries\x86" md "$(TargetDir)NativeBinaries\x86"
xcopy /s /y /d "$(SolutionDir)packages\LibGit2Sharp.0.16.0.0\lib\net35\NativeBinaries\x86\*.*" "$(TargetDir)NativeBinaries\x86"
if not exist "$(TargetDir)NativeBinaries\amd64" md "$(TargetDir)NativeBinaries\amd64"
xcopy /s /y /d "$(SolutionDir)packages\LibGit2Sharp.0.16.0.0\lib\net35\NativeBinaries\amd64\*.*" "$(TargetDir)NativeBinaries\amd64"</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
28 changes: 28 additions & 0 deletions AcceptanceTests/AcceptanceTests.v2.ncrunchproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<ProjectConfiguration>
<CopyReferencedAssembliesToWorkspace>true</CopyReferencedAssembliesToWorkspace>
<ConsiderInconclusiveTestsAsPassing>false</ConsiderInconclusiveTestsAsPassing>
<PreloadReferencedAssemblies>false</PreloadReferencedAssemblies>
<AllowDynamicCodeContractChecking>true</AllowDynamicCodeContractChecking>
<AllowStaticCodeContractChecking>false</AllowStaticCodeContractChecking>
<AllowCodeAnalysis>false</AllowCodeAnalysis>
<IgnoreThisComponentCompletely>false</IgnoreThisComponentCompletely>
<RunPreBuildEvents>true</RunPreBuildEvents>
<RunPostBuildEvents>true</RunPostBuildEvents>
<PreviouslyBuiltSuccessfully>true</PreviouslyBuiltSuccessfully>
<InstrumentAssembly>true</InstrumentAssembly>
<PreventSigningOfAssembly>false</PreventSigningOfAssembly>
<AnalyseExecutionTimes>true</AnalyseExecutionTimes>
<DetectStackOverflow>true</DetectStackOverflow>
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
<DefaultTestTimeout>60000</DefaultTestTimeout>
<UseBuildConfiguration></UseBuildConfiguration>
<UseBuildPlatform></UseBuildPlatform>
<ProxyProcessPath></ProxyProcessPath>
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
<MSTestThreadApartmentState>STA</MSTestThreadApartmentState>
<BuildProcessArchitecture>x86</BuildProcessArchitecture>
<IgnoredTests>
<AllTestsSelector />
</IgnoredTests>
<AdditionalFilesToInclude>..\Packages\LibGit2Sharp.0.16.0.0\lib\net35\NativeBinaries\**.*</AdditionalFilesToInclude>
</ProjectConfiguration>
44 changes: 44 additions & 0 deletions AcceptanceTests/EmptyRepositorySpecification.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using GitHubFlowVersion.AcceptanceTests.Helpers;
using Xunit;

namespace GitHubFlowVersion.AcceptanceTests
{
using System;
using TestStack.BDDfy;

public class EmptyRepositorySpecification : IUseFixture<RepositoryFixture>
{
private ExecutionResults _result;
RepositoryFixture _data;

public void GivenAnEmptyRepository() {}

public void WhenGitHubFlowVersionIsExecuted()
{
_result = GitVersionHelper.ExecuteIn(_data.RepositoryPath);
}

public void ThenANonZeroExitCodeShouldOccur()
{
Assert.NotEqual(0, _result.ExitCode);
}

public void AndAnErrorAboutNotFindingMasterShouldBeShown()
{
Assert.Contains("No Tip found. Has repo been initialized?", _result.Output);
}

[Fact]
public void RunSpecification()
{
// If we are actually running in teamcity, lets delete this environmental variable
Environment.SetEnvironmentVariable("TEAMCITY_VERSION", null);
this.BDDfy();
}

public void SetFixture(RepositoryFixture data)
{
_data = data;
}
}
}
43 changes: 43 additions & 0 deletions AcceptanceTests/ExecArgSpecification.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//using System.IO;
//using GitHubFlowVersion.AcceptanceTests.Helpers;
//using Xunit;

//namespace GitHubFlowVersion.AcceptanceTests
//{
// using global::AcceptanceTests.Properties;

// public class ExecArgSpecification : RepositorySpecification
// {
// private ExecutionResults _result;
// private const string MsBuild = @"c:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe";
// private const string TaggedVersion = "1.2.3";

// public void GivenARepositoryWithATaggedCommit()
// {
// Repository.MakeATaggedCommit(TaggedVersion);
// Repository.MakeACommit();
// }

// public void AndGivenThereIsANextVersionTxtFile()
// {
// Repository.AddNextVersionTxtFile(TaggedVersion);
// }

// public void WhenGitHubFlowVersionIsExecutedWithExecOption()
// {
// var buildFile = Path.Combine(RepositoryPath, "TestBuildFile.proj");
// File.WriteAllBytes(buildFile, Resources.TestBuildFile);
// _result = GitVersionHelper.ExecuteIn(RepositoryPath, exec: MsBuild, execArgs: "TestBuildFile.proj /target:OutputResults");
// }

// public void ThenProcessExitedWithoutError()
// {
// _result.AssertExitedSuccessfully();
// }

// public void AndThenVariablesShouldBeAvailableToProcess()
// {
// Assert.Contains("GitHubFlowVersion_FullSemVer: 1.2.4+001", _result.Output);
// }
// }
//}
21 changes: 21 additions & 0 deletions AcceptanceTests/Helpers/ExecutionResults.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Xunit;

namespace GitHubFlowVersion.AcceptanceTests.Helpers
{
public class ExecutionResults
{
public ExecutionResults(int exitCode, string output)
{
ExitCode = exitCode;
Output = output;
}

public int ExitCode { get; private set; }
public string Output { get; private set; }

public void AssertExitedSuccessfully()
{
Assert.Equal(0, ExitCode);
}
}
}
34 changes: 34 additions & 0 deletions AcceptanceTests/Helpers/GitHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.IO;
using System.Linq;
using LibGit2Sharp;

namespace GitHubFlowVersion.AcceptanceTests.Helpers
{
public static class GitHelper
{
public static Commit MakeACommit(this IRepository repository)
{
var randomFile = Path.Combine(repository.Info.WorkingDirectory, Guid.NewGuid().ToString());
File.WriteAllText(randomFile, string.Empty);
repository.Index.Stage(randomFile);
return repository.Commit("Test Commit", new Signature("Test User", "test@email.com", DateTimeOffset.UtcNow));
}

public static Commit[] MakeCommits(this IRepository repository, int numCommitsToMake)
{
return Enumerable.Range(1, numCommitsToMake)
.Select(x => repository.MakeACommit())
.ToArray();
}

public static Tag MakeATaggedCommit(this IRepository repository, string tag)
{
var commit = repository.MakeACommit();
var existingTag = repository.Tags.SingleOrDefault(t=>t.Name == tag);
if (existingTag != null)
return existingTag;
return repository.Tags.Add(tag, commit);
}
}
}
44 changes: 44 additions & 0 deletions AcceptanceTests/Helpers/GitVersionHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.IO;
using System.Text;
using LibGit2Sharp;

namespace GitHubFlowVersion.AcceptanceTests.Helpers
{
public static class GitVersionHelper
{
public static ExecutionResults ExecuteIn(string workingDirectory, string toFile = null,
string exec = null, string execArgs = null, string projectFile = null, string targets = null)
{
var gitHubFlowVersion = Path.Combine(PathHelper.GetCurrentDirectory(), "GitVersion.exe");
var toFileArg = toFile == null ? null : string.Format(" /ToFile \"{0}\"", toFile);
var execArg = exec == null ? null : string.Format(" /Exec \"{0}\"", exec);
var execArgsArg = execArgs == null ? null : string.Format(" /ExecArgs \"{0}\"", execArgs);
var projectFileArg = projectFile == null ? null : string.Format(" /ProjectFile \"{0}\"", projectFile);
var targetsArg = targets == null ? null : string.Format(" /Targets \"{0}\"", targets);
var arguments = string.Format("\"{0}\"{1}{2}{3}{4}{5}", workingDirectory, toFileArg, execArg, execArgsArg,
projectFileArg, targetsArg);

var output = new StringBuilder();

Console.WriteLine("Executing: {0} {1}", gitHubFlowVersion, arguments);
Console.WriteLine();
var exitCode = ProcessHelper.Run(s => output.AppendLine(s), s => output.AppendLine(s), null, gitHubFlowVersion, arguments, workingDirectory);

Console.WriteLine("Output from GitHubFlowVersion.exe");
Console.WriteLine("-------------------------------------------------------");
Console.WriteLine(output.ToString());
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("-------------------------------------------------------");

return new ExecutionResults(exitCode, output.ToString());
}

public static void AddNextVersionTxtFile(this IRepository repository, string version)
{
var nextVersionFile = Path.Combine(repository.Info.WorkingDirectory, "NextVersion.txt");
File.WriteAllText(nextVersionFile, version);
}
}
}
19 changes: 19 additions & 0 deletions AcceptanceTests/Helpers/PathHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.IO;
using System.Reflection;

namespace GitHubFlowVersion.AcceptanceTests.Helpers
{
public static class PathHelper
{
public static string GetCurrentDirectory()
{
return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
}

public static string GetTempPath()
{
return Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
}
}
}
Loading