Skip to content
Draft
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
5 changes: 5 additions & 0 deletions GVFS/GVFS.FunctionalTests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public static void Main(string[] args)
NUnitRunner runner = new NUnitRunner(args);
runner.AddGlobalSetupIfNeeded("GVFS.FunctionalTests.GlobalSetup");

if (runner.HasCustomArg("--debug"))
{
Debugger.Launch();
}

if (runner.HasCustomArg("--no-shared-gvfs-cache"))
{
Console.WriteLine("Running without a shared git object cache");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using GVFS.FunctionalTests.Properties;
using NUnit.Framework;

namespace GVFS.FunctionalTests.Tests.GitCommands
{
/// <summary>
/// This class is used to reproduce corruption scenarios in the GVFS virtual projection.
/// </summary>
[Category(Categories.GitCommands)]
[TestFixtureSource(typeof(GitRepoTests), nameof(GitRepoTests.ValidateWorkingTree))]
public class CorruptionReproTests : GitRepoTests
{
public CorruptionReproTests(Settings.ValidateWorkingTreeMode validateWorkingTree)
: base(enlistmentPerTest: true, validateWorkingTree: validateWorkingTree)
{
}

/// <summary>
/// Reproduction of a reported issue:
/// Restoring a file after its parent directory was deleted fails with
/// "fatal: could not unlink 'path\to\': Directory not empty"
/// </summary>
[TestCase]
public void RestoreAfterDeleteNesteredDirectory()
{
// Delete a directory with nested subdirectories and files.
this.ValidateNonGitCommand("cmd.exe", "/c \"rmdir /s /q GVFlt_DeleteFileTest\"");

// Restore the working directory.
this.ValidateGitCommand("restore .");

this.FilesShouldMatchCheckoutOfSourceBranch();
}
}
}
17 changes: 17 additions & 0 deletions GVFS/GVFS.FunctionalTests/Tests/GitCommands/GitRepoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,23 @@ protected void ValidateGitCommand(string command, params object[] args)
args);
}

protected void ValidateNonGitCommand(string command, string args = "", bool ignoreErrors = false, bool checkStatus = true)
{
string controlRepoRoot = this.ControlGitRepo.RootPath;
string gvfsRepoRoot = this.Enlistment.RepoRoot;

ProcessResult expectedResult = ProcessHelper.Run(command, args, controlRepoRoot);
ProcessResult actualResult = ProcessHelper.Run(command, args, gvfsRepoRoot);
if (!ignoreErrors)
{
GitHelpers.ErrorsShouldMatch(command, expectedResult, actualResult);
}
if (checkStatus)
{
this.ValidateGitCommand("status");
}
}

protected void ChangeMode(string filePath, ushort mode)
{
string virtualFile = Path.Combine(this.Enlistment.RepoRoot, filePath);
Expand Down
9 changes: 9 additions & 0 deletions GVFS/GVFS.FunctionalTests/Tools/ProcessHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ namespace GVFS.FunctionalTests.Tools
public static class ProcessHelper
{
public static ProcessResult Run(string fileName, string arguments)
{
return Run(fileName, arguments, null);
}

public static ProcessResult Run(string fileName, string arguments, string workingDirectory)
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.UseShellExecute = false;
Expand All @@ -14,6 +19,10 @@ public static ProcessResult Run(string fileName, string arguments)
startInfo.CreateNoWindow = true;
startInfo.FileName = fileName;
startInfo.Arguments = arguments;
if (!string.IsNullOrEmpty(workingDirectory))
{
startInfo.WorkingDirectory = workingDirectory;
}

return Run(startInfo);
}
Expand Down
Loading