Skip to content

Commit 74c2508

Browse files
committed
Merge pull request #876 from asbjornu/feature/fix-travis-build
Fix Travis build
2 parents 28b1572 + 67d5471 commit 74c2508

File tree

7 files changed

+265
-167
lines changed

7 files changed

+265
-167
lines changed

.travis.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ install:
99
- mono .nuget/nuget.exe restore src/GitVersion.sln -Verbosity detailed
1010
- mono .nuget/nuget.exe install NUnit.Runners -Version 3.2.1 -OutputDirectory ./src/packages
1111
script:
12-
- xbuild "./src/GitVersion.sln" /property:Configuration="Debug" /verbosity:detailed
13-
after_script:
14-
- 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"
12+
- xbuild ./src/GitVersion.sln /property:Configuration="Debug" /verbosity:detailed
13+
- 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
14+
15+
# To run a clean build with Mono, executing just one test, do:
16+
# 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/"
Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11
namespace GitVersion.VersionAssemblyInfoResources
22
{
3+
using System;
34
using System.Collections.Generic;
45
using System.IO;
56
using System.Linq;
67
using GitVersionCore.Extensions;
78

89
public class AssemblyVersionInfoTemplates
910
{
10-
static IDictionary<string, FileInfo> assemblyInfoSourceList;
11+
static readonly IDictionary<string, FileInfo> assemblyInfoSourceList;
1112

1213
static AssemblyVersionInfoTemplates()
1314
{
14-
var enclosingNamespace = typeof(AssemblyVersionInfoTemplates).Namespace;
15-
16-
var files = typeof(AssemblyVersionInfoTemplates)
17-
.Assembly
18-
.GetManifestResourceNames()
19-
.Where(n => n.StartsWith(enclosingNamespace ?? string.Empty)).Select(f => new FileInfo(f));
20-
21-
assemblyInfoSourceList = files.ToDictionary(k => k.Extension, v => v);
15+
assemblyInfoSourceList = GetEmbeddedVersionAssemblyFiles().ToDictionary(k => k.Extension, v => v);
2216
}
2317

2418
public static string GetAssemblyInfoTemplateFor(string assemblyInfoFile)
@@ -34,5 +28,19 @@ public static string GetAssemblyInfoTemplateFor(string assemblyInfoFile)
3428
}
3529
return null;
3630
}
31+
32+
private static IEnumerable<FileInfo> GetEmbeddedVersionAssemblyFiles()
33+
{
34+
var enclosingNamespace = typeof(AssemblyVersionInfoTemplates).Namespace;
35+
36+
if (enclosingNamespace == null)
37+
throw new InvalidOperationException("The AssemblyVersionInfoTemplates class is missing its namespace.");
38+
39+
foreach (var name in typeof(AssemblyVersionInfoTemplates).Assembly.GetManifestResourceNames())
40+
{
41+
if (name.StartsWith(enclosingNamespace))
42+
yield return new FileInfo(name);
43+
}
44+
}
3745
}
3846
}

src/GitVersionExe.Tests/ArgumentParserTests.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,12 @@ public void Wrong_number_of_arguments_should_throw()
165165
exception.Message.ShouldBe("Could not parse command line parameter 'extraArg'.");
166166
}
167167

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

175176
[TestCase("-updateAssemblyInfo true")]
@@ -266,23 +267,23 @@ public void can_log_to_console()
266267
public void nofetch_true_when_defined()
267268
{
268269
var arguments = ArgumentParser.ParseArguments("-nofetch");
269-
arguments.NoFetch = true;
270+
arguments.NoFetch.ShouldBe(true);
270271
}
271272

272273
[Test]
273274
public void other_arguments_can_be_parsed_before_nofetch()
274275
{
275276
var arguments = ArgumentParser.ParseArguments("targetpath -nofetch ");
276-
arguments.TargetPath = "targetpath";
277-
arguments.NoFetch = true;
277+
arguments.TargetPath.ShouldBe("targetpath");
278+
arguments.NoFetch.ShouldBe(true);
278279
}
279280

280281
[Test]
281282
public void other_arguments_can_be_parsed_after_nofetch()
282283
{
283284
var arguments = ArgumentParser.ParseArguments("-nofetch -proj foo.sln");
284-
arguments.NoFetch = true;
285-
arguments.Proj = "foo.sln";
285+
arguments.NoFetch.ShouldBe(true);
286+
arguments.Proj.ShouldBe("foo.sln");
286287
}
287288

288289
[Test]

0 commit comments

Comments
 (0)