Skip to content

Commit af4e947

Browse files
committed
(test) Cleanup NoMono test category, now it applies to mono only, fixed .net core unix tests
1 parent 822ec81 commit af4e947

File tree

12 files changed

+48
-62
lines changed

12 files changed

+48
-62
lines changed

build/pack.cake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Task("Test")
6363
CoverletOutputName = $"{projectName}.coverage.xml"
6464
};
6565

66-
if (IsRunningOnUnix())
66+
if (IsRunningOnUnix() && string.Equals(framework, parameters.FullFxVersion))
6767
{
6868
settings.Filter = "TestCategory!=NoMono";
6969
}

src/GitVersionCore.Tests/AssemblyInfoFileUpdaterTests.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
[TestFixture]
1212
[Parallelizable(ParallelScope.None)]
13-
public class AssemblyInfoFileUpdaterTests
13+
public class AssemblyInfoFileUpdaterTests : TestBase
1414
{
1515
[SetUp]
1616
public void Setup()
@@ -143,8 +143,6 @@ public void ShouldStartSearchFromWorkingDirectory()
143143
[TestCase("cs", "[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyInformationalVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]")]
144144
[TestCase("fs", "[<assembly: AssemblyVersion(\"1.0.0.0\")>]\r\n[<assembly: AssemblyInformationalVersion(\"1.0.0.0\")>]\r\n[<assembly: AssemblyFileVersion(\"1.0.0.0\")>]")]
145145
[TestCase("vb", "<Assembly: AssemblyVersion(\"1.0.0.0\")>\r\n<Assembly: AssemblyInformationalVersion(\"1.0.0.0\")>\r\n<Assembly: AssemblyFileVersion(\"1.0.0.0\")>")]
146-
[Category("NoMono")]
147-
[Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")]
148146
public void ShouldReplaceAssemblyVersion(string fileExtension, string assemblyFileContent)
149147
{
150148
var workingDir = Path.GetTempPath();
@@ -191,8 +189,6 @@ public void ShouldNotReplaceAssemblyVersionWhenVersionSchemeIsNone(string fileEx
191189
[TestCase("cs", "[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyInformationalVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]")]
192190
[TestCase("fs", "[<assembly: AssemblyVersion(\"1.0.0.0\")>]\r\n[<assembly: AssemblyInformationalVersion(\"1.0.0.0\")>]\r\n[<assembly: AssemblyFileVersion(\"1.0.0.0\")>]")]
193191
[TestCase("vb", "<Assembly: AssemblyVersion(\"1.0.0.0\")>\r\n<Assembly: AssemblyInformationalVersion(\"1.0.0.0\")>\r\n<Assembly: AssemblyFileVersion(\"1.0.0.0\")>")]
194-
[Category("NoMono")]
195-
[Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")]
196192
public void ShouldReplaceAssemblyVersionInRelativePath(string fileExtension, string assemblyFileContent)
197193
{
198194
var workingDir = Path.GetTempPath();
@@ -239,8 +235,6 @@ public void ShouldReplaceAssemblyVersionInRelativePathWithWhiteSpace(string file
239235
[TestCase("cs", "[assembly: AssemblyVersion(\"1.0.0.*\")]\r\n[assembly: AssemblyInformationalVersion(\"1.0.0.*\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.*\")]")]
240236
[TestCase("fs", "[<assembly: AssemblyVersion(\"1.0.0.*\")>]\r\n[<assembly: AssemblyInformationalVersion(\"1.0.0.*\")>]\r\n[<assembly: AssemblyFileVersion(\"1.0.0.*\")>]")]
241237
[TestCase("vb", "<Assembly: AssemblyVersion(\"1.0.0.*\")>\r\n<Assembly: AssemblyInformationalVersion(\"1.0.0.*\")>\r\n<Assembly: AssemblyFileVersion(\"1.0.0.*\")>")]
242-
[Category("NoMono")]
243-
[Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")]
244238
public void ShouldReplaceAssemblyVersionWithStar(string fileExtension, string assemblyFileContent)
245239
{
246240
var workingDir = Path.GetTempPath();
@@ -264,8 +258,6 @@ public void ShouldReplaceAssemblyVersionWithStar(string fileExtension, string as
264258
[TestCase("cs", "[assembly: AssemblyVersionAttribute(\"1.0.0.0\")]\r\n[assembly: AssemblyInformationalVersionAttribute(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersionAttribute(\"1.0.0.0\")]")]
265259
[TestCase("fs", "[<assembly: AssemblyVersionAttribute(\"1.0.0.0\")>]\r\n[<assembly: AssemblyInformationalVersionAttribute(\"1.0.0.0\")>]\r\n[<assembly: AssemblyFileVersionAttribute(\"1.0.0.0\")>]")]
266260
[TestCase("vb", "<Assembly: AssemblyVersionAttribute(\"1.0.0.0\")>\r\n<Assembly: AssemblyInformationalVersionAttribute(\"1.0.0.0\")>\r\n<Assembly: AssemblyFileVersionAttribute(\"1.0.0.0\")>")]
267-
[Category("NoMono")]
268-
[Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")]
269261
public void ShouldReplaceAssemblyVersionWithAtttributeSuffix(string fileExtension, string assemblyFileContent)
270262
{
271263
var workingDir = Path.GetTempPath();
@@ -315,8 +307,6 @@ public void ShouldAddAssemblyVersionIfMissingFromInfoFile(string fileExtension)
315307
[TestCase("cs", "[assembly: AssemblyVersion(\"2.2.0.0\")]\r\n[assembly: AssemblyInformationalVersion(\"2.2.0+5.Branch.foo.Sha.hash\")]\r\n[assembly: AssemblyFileVersion(\"2.2.0.0\")]")]
316308
[TestCase("fs", "[<assembly: AssemblyVersion(\"2.2.0.0\")>]\r\n[<assembly: AssemblyInformationalVersion(\"2.2.0+5.Branch.foo.Sha.hash\")>]\r\n[<assembly: AssemblyFileVersion(\"2.2.0.0\")>]")]
317309
[TestCase("vb", "<Assembly: AssemblyVersion(\"2.2.0.0\")>\r\n<Assembly: AssemblyInformationalVersion(\"2.2.0+5.Branch.foo.Sha.hash\")>\r\n<Assembly: AssemblyFileVersion(\"2.2.0.0\")>")]
318-
[Category("NoMono")]
319-
[Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")]
320310
public void ShouldReplaceAlreadySubstitutedValues(string fileExtension, string assemblyFileContent)
321311
{
322312
var workingDir = Path.GetTempPath();
@@ -340,8 +330,6 @@ public void ShouldReplaceAlreadySubstitutedValues(string fileExtension, string a
340330
[TestCase("cs", "[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyInformationalVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]")]
341331
[TestCase("fs", "[<assembly: AssemblyVersion(\"1.0.0.0\")>]\r\n[<assembly: AssemblyInformationalVersion(\"1.0.0.0\")>]\r\n[<assembly: AssemblyFileVersion(\"1.0.0.0\")>]")]
342332
[TestCase("vb", "<Assembly: AssemblyVersion(\"1.0.0.0\")>\r\n<Assembly: AssemblyInformationalVersion(\"1.0.0.0\")>\r\n<Assembly: AssemblyFileVersion(\"1.0.0.0\")>")]
343-
[Category("NoMono")]
344-
[Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")]
345333
public void ShouldReplaceAssemblyVersionWhenCreatingAssemblyVersionFileAndEnsureAssemblyInfo(string fileExtension, string assemblyFileContent)
346334
{
347335
var workingDir = Path.GetTempPath();

src/GitVersionCore.Tests/ConfigProviderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ public void NextVersionCanHavePatch()
179179
}
180180

181181
[Test]
182+
[MethodImpl(MethodImplOptions.NoInlining)]
182183
[Category("NoMono")]
183184
[Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")]
184-
[MethodImpl(MethodImplOptions.NoInlining)]
185185
public void CanWriteOutEffectiveConfiguration()
186186
{
187187
var config = ConfigurationProvider.GetEffectiveConfigAsString(repoPath, fileSystem, configFileLocator);

src/GitVersionCore.Tests/Init/InitScenarios.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
namespace GitVersionCore.Tests.Init
22
{
3+
using System.IO;
4+
using System.Runtime.InteropServices;
35
using GitVersion;
46
using NUnit.Framework;
57
using Shouldly;
@@ -21,9 +23,10 @@ public void CanSetNextVersion()
2123
var testFileSystem = new TestFileSystem();
2224
var testConsole = new TestConsole("3", "2.0.0", "0");
2325
var configFileLocator = new DefaultConfigFileLocator();
24-
ConfigurationProvider.Init("c:\\proj", testFileSystem, testConsole, configFileLocator);
26+
var workingDirectory = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "c:\\proj" : "/proj";
27+
ConfigurationProvider.Init(workingDirectory, testFileSystem, testConsole, configFileLocator);
2528

26-
testFileSystem.ReadAllText("c:\\proj\\GitVersion.yml").ShouldMatchApproved();
29+
testFileSystem.ReadAllText(Path.Combine(workingDirectory, "GitVersion.yml")).ShouldMatchApproved();
2730
}
2831
}
2932
}

src/GitVersionCore.Tests/WixFileTests.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@ public void UpdateWixVersionFile()
4646
using (var wixVersionFileUpdater = new WixVersionFileUpdater(workingDir, vars, fileSystem))
4747
{
4848
wixVersionFileUpdater.Update();
49+
fileSystem.ReadAllText(wixVersionFileUpdater.WixVersionFile).
50+
ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved")));
4951
}
50-
51-
fileSystem.ReadAllText(WixVersionFileUpdater.GetWixVersionFileName()).
52-
ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved")));
5352
}
5453
}
5554
}

src/GitVersionCore/VersionAssemblyInfoResources/AssemblyInfoFileUpdater.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public class AssemblyInfoFileUpdater : IDisposable
1919
{".vb", new Regex( @"(\s*\<Assembly:\s*(?:.*)\>\s*$(\r?\n)?)", RegexOptions.Multiline) },
2020
};
2121

22+
private const string NewLine = "\r\n";
23+
2224
ISet<string> assemblyInfoFileNames;
2325
string workingDirectory;
2426
VersionVariables variables;
@@ -62,9 +64,9 @@ public void Update()
6264

6365
foreach (var assemblyInfoFile in assemblyInfoFiles)
6466
{
65-
var backupAssemblyInfo = assemblyInfoFile.FullName + ".bak";
6667
var localAssemblyInfo = assemblyInfoFile.FullName;
67-
fileSystem.Copy(assemblyInfoFile.FullName, backupAssemblyInfo, true);
68+
var backupAssemblyInfo = localAssemblyInfo + ".bak";
69+
fileSystem.Copy(localAssemblyInfo, backupAssemblyInfo, true);
6870

6971
restoreBackupTasks.Add(() =>
7072
{
@@ -78,7 +80,7 @@ public void Update()
7880

7981
cleanupBackupTasks.Add(() => fileSystem.Delete(backupAssemblyInfo));
8082

81-
var originalFileContents = fileSystem.ReadAllText(assemblyInfoFile.FullName);
83+
var originalFileContents = fileSystem.ReadAllText(localAssemblyInfo);
8284
var fileContents = originalFileContents;
8385
var appendedAttributes = false;
8486

@@ -97,12 +99,12 @@ public void Update()
9799
if (appendedAttributes)
98100
{
99101
// If we appended any attributes, put a new line after them
100-
fileContents += Environment.NewLine;
102+
fileContents += NewLine;
101103
}
102104

103105
if (originalFileContents != fileContents)
104106
{
105-
fileSystem.WriteAllText(assemblyInfoFile.FullName, fileContents);
107+
fileSystem.WriteAllText(localAssemblyInfo, fileContents);
106108
}
107109
}
108110
}
@@ -123,14 +125,14 @@ string ReplaceOrInsertAfterLastAssemblyAttributeOrAppend(Regex replaceRegex, str
123125
{
124126
var lastMatch = assemblyMatches[assemblyMatches.Count - 1];
125127
var replacementString = lastMatch.Value;
126-
if (!lastMatch.Value.EndsWith(Environment.NewLine)) replacementString += Environment.NewLine;
128+
if (!lastMatch.Value.EndsWith(NewLine)) replacementString += NewLine;
127129
replacementString += string.Format(assemblyAddFormat, replaceString);
128-
replacementString += Environment.NewLine;
130+
replacementString += NewLine;
129131
return inputString.Replace(lastMatch.Value, replacementString);
130132
}
131133
}
132134

133-
inputString += Environment.NewLine + string.Format(assemblyAddFormat, replaceString);
135+
inputString += NewLine + string.Format(assemblyAddFormat, replaceString);
134136
appendedAttributes = true;
135137
return inputString;
136138
}

src/GitVersionCore/WixVersionFileUpdater.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,22 @@ namespace GitVersion
33
using Helpers;
44

55
using System;
6+
using System.IO;
67
using System.Text;
78
using System.Xml;
89

910
public class WixVersionFileUpdater : IDisposable
1011
{
11-
string workingDirectory;
1212
VersionVariables variables;
1313
IFileSystem fileSystem;
14-
private const string WIX_VERSION_FILE = "GitVersion_WixVersion.wxi ";
14+
public string WixVersionFile { get; }
15+
public const string WIX_VERSION_FILE = "GitVersion_WixVersion.wxi";
1516

1617
public WixVersionFileUpdater(string workingDirectory, VersionVariables variables, IFileSystem fileSystem)
1718
{
18-
this.workingDirectory = workingDirectory;
1919
this.variables = variables;
2020
this.fileSystem = fileSystem;
21-
}
22-
23-
public static string GetWixVersionFileName()
24-
{
25-
return WIX_VERSION_FILE;
21+
this.WixVersionFile = Path.Combine(workingDirectory, WIX_VERSION_FILE);
2622
}
2723

2824
public void Update()
@@ -36,7 +32,7 @@ public void Update()
3632
XmlElement root = doc.DocumentElement;
3733
doc.InsertBefore(xmlDecl, root);
3834

39-
using (var fs = fileSystem.OpenWrite(WIX_VERSION_FILE))
35+
using (var fs = fileSystem.OpenWrite(WixVersionFile))
4036
{
4137
doc.Save(fs);
4238
}
@@ -58,7 +54,7 @@ private string GetWixFormatFromVersionVariables()
5854

5955
public void Dispose()
6056
{
61-
Logger.WriteInfo($"Done writing {WIX_VERSION_FILE}");
57+
Logger.WriteInfo($"Done writing {WixVersionFile}");
6258
}
6359
}
6460
}

src/GitVersionExe.Tests/ArgumentBuilder.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Text;
1+
using System.Text;
22

33
public class ArgumentBuilder
44
{
@@ -40,7 +40,7 @@ public override string ToString()
4040
{
4141
var arguments = new StringBuilder();
4242

43-
arguments.AppendFormat("\"{0}\"", workingDirectory);
43+
arguments.AppendFormat(" /targetpath \"{0}\"", workingDirectory);
4444

4545
if (!string.IsNullOrWhiteSpace(exec))
4646
{
@@ -62,13 +62,13 @@ public override string ToString()
6262
arguments.AppendFormat(" /projargs \"{0}\"", projectArgs);
6363
}
6464

65-
arguments.Append(additionalArguments);
66-
6765
if (!string.IsNullOrWhiteSpace(logFile))
6866
{
6967
arguments.AppendFormat(" /l \"{0}\"", logFile);
7068
}
7169

70+
arguments.Append(additionalArguments);
71+
7272
return arguments.ToString();
7373
}
7474

@@ -81,4 +81,4 @@ public override string ToString()
8181
readonly string projectArgs;
8282
readonly string projectFile;
8383
readonly string workingDirectory;
84-
}
84+
}

src/GitVersionExe.Tests/ExecCmdLineArgumentTest.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,16 @@ public void WorkingDirectoryWithoutGitFolderCrashesWithInformativeMessage()
8989
}
9090

9191
[Test]
92-
[Category("NoMono")]
93-
[Description("Doesn't work on Mono/Unix because of the path heuristics that needs to be done there in order to figure out whether the first argument actually is a path.")]
9492
public void WorkingDirectoryDoesNotExistCrashesWithInformativeMessage()
9593
{
9694
var workingDirectory = Path.Combine(PathHelper.GetCurrentDirectory(), Guid.NewGuid().ToString("N"));
9795
var executable = PathHelper.GetExecutable();
9896

9997
var output = new StringBuilder();
100-
var args = PathHelper.GetExecutableArgs(workingDirectory);
98+
var args = PathHelper.GetExecutableArgs($" /targetpath {workingDirectory} ");
99+
100+
Console.WriteLine("Executing: {0} {1}", executable, args);
101+
Console.WriteLine();
101102

102103
var exitCode = ProcessHelper.Run(
103104
s => output.AppendLine(s),

src/GitVersionExe.Tests/GitVersionHelper.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ static ExecutionResults ExecuteIn(ArgumentBuilder arguments)
3232
var executable = PathHelper.GetExecutable();
3333
var output = new StringBuilder();
3434

35-
Console.WriteLine("Executing: {0} {1}", executable, arguments);
36-
Console.WriteLine();
3735
var environmentalVariables =
3836
new[]
3937
{
@@ -49,9 +47,16 @@ static ExecutionResults ExecuteIn(ArgumentBuilder arguments)
4947
{
5048
var args = PathHelper.GetExecutableArgs(arguments.ToString());
5149

50+
Console.WriteLine("Executing: {0} {1}", executable, args);
51+
Console.WriteLine();
52+
5253
exitCode = ProcessHelper.Run(
53-
s => output.AppendLine(s), s => output.AppendLine(s), null,
54-
executable, args, arguments.WorkingDirectory,
54+
s => output.AppendLine(s),
55+
s => output.AppendLine(s),
56+
null,
57+
executable,
58+
args,
59+
arguments.WorkingDirectory,
5560
environmentalVariables);
5661
}
5762
catch (Exception exception)

src/GitVersionExe.Tests/UpdateWixVersionFileTests.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,23 @@ class UpdateWixVersionFileTests
1818
[SetUp]
1919
public void Setup()
2020
{
21-
WixVersionFileName = WixVersionFileUpdater.GetWixVersionFileName();
21+
WixVersionFileName = WixVersionFileUpdater.WIX_VERSION_FILE;
2222
}
2323

2424
[Test]
25-
[Category("NoMono")]
26-
[Description("Doesn't work on Mono/Unix because of the path heuristics that needs to be done there in order to figure out whether the first argument actually is a path.")]
2725
public void WixVersionFileCreationTest()
2826
{
2927
using (var fixture = new EmptyRepositoryFixture())
3028
{
3129
fixture.MakeATaggedCommit("1.2.3");
3230
fixture.MakeACommit();
3331

34-
GitVersionHelper.ExecuteIn(fixture.RepositoryPath, arguments: " -updatewixversionfile");
32+
GitVersionHelper.ExecuteIn(fixture.RepositoryPath, arguments: " /updatewixversionfile");
3533
Assert.IsTrue(File.Exists(Path.Combine(fixture.RepositoryPath, WixVersionFileName)));
3634
}
3735
}
3836

3937
[Test]
40-
[Category("NoMono")]
41-
[Description("Doesn't work on Mono/Unix because of the path heuristics that needs to be done there in order to figure out whether the first argument actually is a path.")]
4238
public void WixVersionFileVarCountTest()
4339
{
4440
//Make sure we have captured all the version variables by count in the Wix version file
@@ -50,7 +46,7 @@ public void WixVersionFileVarCountTest()
5046
var gitVersionExecutionResults = GitVersionHelper.ExecuteIn(fixture.RepositoryPath, arguments: null);
5147
var vars = gitVersionExecutionResults.OutputVariables;
5248

53-
GitVersionHelper.ExecuteIn(fixture.RepositoryPath, arguments: " -updatewixversionfile");
49+
GitVersionHelper.ExecuteIn(fixture.RepositoryPath, arguments: " /updatewixversionfile");
5450

5551
var gitVersionVarsInWix = GetGitVersionVarsInWixFile(Path.Combine(fixture.RepositoryPath, WixVersionFileName));
5652
var gitVersionVars = VersionVariables.AvailableVariables;
@@ -60,8 +56,6 @@ public void WixVersionFileVarCountTest()
6056
}
6157

6258
[Test]
63-
[Category("NoMono")]
64-
[Description("Doesn't work on Mono/Unix because of the path heuristics that needs to be done there in order to figure out whether the first argument actually is a path.")]
6559
public void WixVersionFileContentTest()
6660
{
6761
using (var fixture = new EmptyRepositoryFixture())
@@ -72,7 +66,7 @@ public void WixVersionFileContentTest()
7266
var gitVersionExecutionResults = GitVersionHelper.ExecuteIn(fixture.RepositoryPath, arguments: null);
7367
VersionVariables vars = gitVersionExecutionResults.OutputVariables;
7468

75-
GitVersionHelper.ExecuteIn(fixture.RepositoryPath, arguments: " -updatewixversionfile");
69+
GitVersionHelper.ExecuteIn(fixture.RepositoryPath, arguments: " /updatewixversionfile");
7670

7771
var gitVersionVarsInWix = GetGitVersionVarsInWixFile(Path.Combine(fixture.RepositoryPath, WixVersionFileName));
7872
var gitVersionVars = VersionVariables.AvailableVariables;

src/GitVersionExe.Tests/VersionWriterTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ public void WriteVersion_ShouldWriteFileVersion_WithNoPrereleaseTag()
2323
}
2424

2525
[Test]
26-
[Category("NoMono")]
27-
[Description("Seems assembly info is slightly different on mono, this test fails with no pre-release info.")]
2826
public void WriteVersion_ShouldWriteFileVersion_WithPrereleaseTag()
2927
{
3028
var asm = GenerateAssembly(new Version(1, 0, 0), "-beta0004");

0 commit comments

Comments
 (0)