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
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ install:
- mono .nuget/nuget.exe restore src/GitVersion.sln -Verbosity detailed
- mono .nuget/nuget.exe install NUnit.Runners -Version 3.2.1 -OutputDirectory ./src/packages
script:
- xbuild "./src/GitVersion.sln" /property:Configuration="Debug" /verbosity:detailed
after_script:
- mono --debug --runtime=v4.0.30319 ./src/packages/NUnit.ConsoleRunner.3.2.1/tools/nunit3-console.exe ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionCore.Tests/bin/Debug/GitVersionCore.Tests.dll ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionExe.Tests/bin/Debug/GitVersionExe.Tests.dll -where "cat != NoMono"
- xbuild ./src/GitVersion.sln /property:Configuration="Debug" /verbosity:detailed
- mono ./src/packages/NUnit.ConsoleRunner.3.2.1/tools/nunit3-console.exe ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionCore.Tests/bin/Debug/GitVersionCore.Tests.dll ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionExe.Tests/bin/Debug/GitVersionExe.Tests.dll --where "cat != NoMono" --noresult

# To run a clean build with Mono, executing just one test, do:
# xbuild ./src/GitVersion.sln /t:Clean /verbosity:quiet && xbuild ./src/GitVersion.sln /property:Configuration="Debug" /verbosity:quiet && mono ./src/packages/NUnit.ConsoleRunner.3.2.1/tools/nunit3-console.exe ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionCore.Tests/bin/Debug/GitVersionCore.Tests.dll ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionExe.Tests/bin/Debug/GitVersionExe.Tests.dll --noresult --where "test =~ /TheNameOfTheTest/"
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
namespace GitVersion.VersionAssemblyInfoResources
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using GitVersionCore.Extensions;

public class AssemblyVersionInfoTemplates
{
static IDictionary<string, FileInfo> assemblyInfoSourceList;
static readonly IDictionary<string, FileInfo> assemblyInfoSourceList;

static AssemblyVersionInfoTemplates()
{
var enclosingNamespace = typeof(AssemblyVersionInfoTemplates).Namespace;

var files = typeof(AssemblyVersionInfoTemplates)
.Assembly
.GetManifestResourceNames()
.Where(n => n.StartsWith(enclosingNamespace ?? string.Empty)).Select(f => new FileInfo(f));

assemblyInfoSourceList = files.ToDictionary(k => k.Extension, v => v);
assemblyInfoSourceList = GetEmbeddedVersionAssemblyFiles().ToDictionary(k => k.Extension, v => v);
}

public static string GetAssemblyInfoTemplateFor(string assemblyInfoFile)
Expand All @@ -34,5 +28,19 @@ public static string GetAssemblyInfoTemplateFor(string assemblyInfoFile)
}
return null;
}

private static IEnumerable<FileInfo> GetEmbeddedVersionAssemblyFiles()
{
var enclosingNamespace = typeof(AssemblyVersionInfoTemplates).Namespace;

if (enclosingNamespace == null)
throw new InvalidOperationException("The AssemblyVersionInfoTemplates class is missing its namespace.");

foreach (var name in typeof(AssemblyVersionInfoTemplates).Assembly.GetManifestResourceNames())
{
if (name.StartsWith(enclosingNamespace))
yield return new FileInfo(name);
}
}
}
}
19 changes: 10 additions & 9 deletions src/GitVersionExe.Tests/ArgumentParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,12 @@ public void Wrong_number_of_arguments_should_throw()
exception.Message.ShouldBe("Could not parse command line parameter 'extraArg'.");
}

[Test]
public void Unknown_argument_should_throw()
[TestCase("targetDirectoryPath -x logFilePath")]
[TestCase("/invalid-argument")]
public void Unknown_arguments_should_throw(string arguments)
{
var exception = Assert.Throws<WarningException>(() => ArgumentParser.ParseArguments("targetDirectoryPath -x logFilePath"));
exception.Message.ShouldBe("Could not parse command line parameter '-x'.");
var exception = Assert.Throws<WarningException>(() => ArgumentParser.ParseArguments(arguments));
exception.Message.ShouldStartWith("Could not parse command line parameter");
}

[TestCase("-updateAssemblyInfo true")]
Expand Down Expand Up @@ -266,23 +267,23 @@ public void can_log_to_console()
public void nofetch_true_when_defined()
{
var arguments = ArgumentParser.ParseArguments("-nofetch");
arguments.NoFetch = true;
arguments.NoFetch.ShouldBe(true);
}

[Test]
public void other_arguments_can_be_parsed_before_nofetch()
{
var arguments = ArgumentParser.ParseArguments("targetpath -nofetch ");
arguments.TargetPath = "targetpath";
arguments.NoFetch = true;
arguments.TargetPath.ShouldBe("targetpath");
arguments.NoFetch.ShouldBe(true);
}

[Test]
public void other_arguments_can_be_parsed_after_nofetch()
{
var arguments = ArgumentParser.ParseArguments("-nofetch -proj foo.sln");
arguments.NoFetch = true;
arguments.Proj = "foo.sln";
arguments.NoFetch.ShouldBe(true);
arguments.Proj.ShouldBe("foo.sln");
}

[Test]
Expand Down
Loading