Skip to content

Commit 1765942

Browse files
committed
Added test for having a non-existing path as working directory
1 parent d7cacc5 commit 1765942

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/GitVersionExe.Tests/ExecCmdLineArgumentTest.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.IO;
4+
using System.Text;
5+
using GitTools;
36
using GitTools.Testing;
47
using GitVersion;
58
using NUnit.Framework;
@@ -66,4 +69,25 @@ public void WorkingDirectoryWithoutGitFolderCrashesWithInformativeMessage()
6669
var results = GitVersionHelper.ExecuteIn(Environment.SystemDirectory, null, isTeamCity: false, logToFile: false);
6770
results.Output.ShouldContain("Can't find the .git directory in");
6871
}
72+
73+
[Test]
74+
[Category("NoMono")]
75+
[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.")]
76+
public void WorkingDirectoryDoesNotExistCrashesWithInformativeMessage()
77+
{
78+
var workingDirectory = Path.Combine(Environment.CurrentDirectory, Guid.NewGuid().ToString("N"));
79+
var gitVersion = Path.Combine(PathHelper.GetCurrentDirectory(), "GitVersion.exe");
80+
var output = new StringBuilder();
81+
var exitCode = ProcessHelper.Run(
82+
s => output.AppendLine(s),
83+
s => output.AppendLine(s),
84+
null,
85+
gitVersion,
86+
workingDirectory,
87+
Environment.CurrentDirectory);
88+
89+
exitCode.ShouldNotBe(0);
90+
var outputString = output.ToString();
91+
outputString.ShouldContain(string.Format("The working directory '{0}' does not exist.", workingDirectory), () => outputString);
92+
}
6993
}

0 commit comments

Comments
 (0)