Skip to content

Commit 4177904

Browse files
committed
Added test that verifies the exit code when invalid arguments are passed to GitVersionExe. The exit code should be 1 (not 0).
1 parent 06f55b1 commit 4177904

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

GitVersionExe.Tests/ExecCmdLineArgumentTest.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.IO;
1+
using System;
2+
using System.IO;
23
using NUnit.Framework;
34
using Shouldly;
45

@@ -30,4 +31,28 @@ public void RunExecViaCommandLine()
3031
result.Log.ShouldContain("GitVersion_FullSemVer: 1.2.4+1");
3132
}
3233
}
34+
35+
[Test]
36+
public void InvalidArgumentsExitCodeShouldNotBeZero()
37+
{
38+
using (var fixture = new EmptyRepositoryFixture())
39+
{
40+
fixture.Repository.MakeATaggedCommit("1.2.3");
41+
fixture.Repository.MakeACommit();
42+
43+
var buildFile = Path.Combine(fixture.RepositoryPath, "RunExecViaCommandLine.proj");
44+
File.Delete(buildFile);
45+
const string buildFileContent = @"<?xml version=""1.0"" encoding=""utf-8""?>
46+
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
47+
<Target Name=""OutputResults"">
48+
<Message Text=""GitVersion_FullSemVer: $(GitVersion_FullSemVer)""/>
49+
</Target>
50+
</Project>";
51+
File.WriteAllText(buildFile, buildFileContent);
52+
var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath, arguments: " /invalid-argument");
53+
54+
result.ExitCode.ShouldBe(1);
55+
result.Output.ShouldContain("Failed to parse arguments");
56+
}
57+
}
3358
}

0 commit comments

Comments
 (0)