Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac: Run GitRepoTests with and without validating the working directory during setup #445

Merged
merged 5 commits into from
Oct 31, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions GVFS/GVFS.FunctionalTests/GVFSTestConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public static class GVFSTestConfig

public static object[] FileSystemRunners { get; set; }

public static object[] GitCommandTestWorkTreeValidation { get; set; }

public static bool TestGVFSOnPath { get; set; }

public static bool ReplaceInboxProjFS { get; set; }
Expand Down
13 changes: 13 additions & 0 deletions GVFS/GVFS.FunctionalTests/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using GVFS.FunctionalTests.Tests;
using GVFS.FunctionalTests.Tests.GitCommands;
using GVFS.FunctionalTests.Tools;
using GVFS.Tests;
using System;
Expand Down Expand Up @@ -43,6 +44,13 @@ public static void Main(string[] args)
{
Console.WriteLine("Running the full suite of tests");

GVFSTestConfig.GitCommandTestWorkTreeValidation =
new object[]
{
new object[] { GitRepoTests.ValidateWorkingTreeOptions.ValidateWorkingTree },
new object[] { GitRepoTests.ValidateWorkingTreeOptions.DoNotValidateWorkingTree }
};

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
GVFSTestConfig.FileSystemRunners = FileSystemRunners.FileSystemRunner.AllWindowsRunners;
Expand All @@ -56,6 +64,11 @@ public static void Main(string[] args)
{
excludeCategories.Add(Categories.FullSuiteOnly);
GVFSTestConfig.FileSystemRunners = FileSystemRunners.FileSystemRunner.DefaultRunners;
GVFSTestConfig.GitCommandTestWorkTreeValidation =
new object[]
{
new object[] { GitRepoTests.ValidateWorkingTreeOptions.ValidateWorkingTree }
};
}

if (runner.HasCustomArg("--windows-only"))
Expand Down
5 changes: 3 additions & 2 deletions GVFS/GVFS.FunctionalTests/Tests/GitCommands/AddStageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@

namespace GVFS.FunctionalTests.Tests.GitCommands
{
[TestFixture]
[TestFixtureSource(typeof(GitRepoTests), GitRepoTests.ValidateWorkingTree)]
[Category(Categories.GitCommands)]
public class AddStageTests : GitRepoTests
{
public AddStageTests() : base(enlistmentPerTest: false)
public AddStageTests(ValidateWorkingTreeOptions validateWorkingTree)
: base(enlistmentPerTest: false, validateWorkingTree: validateWorkingTree)
{
}

Expand Down
5 changes: 3 additions & 2 deletions GVFS/GVFS.FunctionalTests/Tests/GitCommands/CheckoutTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@

namespace GVFS.FunctionalTests.Tests.GitCommands
{
[TestFixture]
[TestFixtureSource(typeof(GitRepoTests), GitRepoTests.ValidateWorkingTree)]
[Category(Categories.GitCommands)]
public class CheckoutTests : GitRepoTests
{
public CheckoutTests() : base(enlistmentPerTest: true)
public CheckoutTests(ValidateWorkingTreeOptions validateWorkingTree)
: base(enlistmentPerTest: true, validateWorkingTree: validateWorkingTree)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace GVFS.FunctionalTests.Tests.GitCommands
{
[TestFixture]
[TestFixtureSource(typeof(GitRepoTests), GitRepoTests.ValidateWorkingTree)]
[Category(Categories.GitCommands)]
public class CherryPickConflictTests : GitRepoTests
{
public CherryPickConflictTests() : base(enlistmentPerTest: true)
public CherryPickConflictTests(ValidateWorkingTreeOptions validateWorkingTree)
: base(enlistmentPerTest: true, validateWorkingTree: validateWorkingTree)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@

namespace GVFS.FunctionalTests.Tests.GitCommands
{
[TestFixture]
[TestFixtureSource(typeof(GitRepoTests), GitRepoTests.ValidateWorkingTree)]
[Category(Categories.GitCommands)]
public class CreatePlaceholderTests : GitRepoTests
{
private static readonly string FileToRead = Path.Combine("GVFS", "GVFS", "Program.cs");

public CreatePlaceholderTests() : base(enlistmentPerTest: true)
public CreatePlaceholderTests(ValidateWorkingTreeOptions validateWorkingTree)
: base(enlistmentPerTest: true, validateWorkingTree: validateWorkingTree)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

namespace GVFS.FunctionalTests.Tests.GitCommands
{
[TestFixture]
[TestFixtureSource(typeof(GitRepoTests), GitRepoTests.ValidateWorkingTree)]
[Category(Categories.GitCommands)]
public class DeleteEmptyFolderTests : GitRepoTests
{
public DeleteEmptyFolderTests() : base(enlistmentPerTest: true)
public DeleteEmptyFolderTests(ValidateWorkingTreeOptions validateWorkingTree)
: base(enlistmentPerTest: true, validateWorkingTree: validateWorkingTree)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

namespace GVFS.FunctionalTests.Tests.GitCommands
{
[TestFixture]
[TestFixtureSource(typeof(GitRepoTests), GitRepoTests.ValidateWorkingTree)]
[Category(Categories.GitCommands)]
public class EnumerationMergeTest : GitRepoTests
{
// Commit that found GvFlt Bug 12258777: Entries are sometimes skipped during
// enumeration when they don't fit in a user's buffer
private const string EnumerationReproCommitish = "FunctionalTests/20170602";

public EnumerationMergeTest() : base(enlistmentPerTest: true)
public EnumerationMergeTest(ValidateWorkingTreeOptions validateWorkingTree)
: base(enlistmentPerTest: true, validateWorkingTree: validateWorkingTree)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace GVFS.FunctionalTests.Tests.GitCommands
{
[TestFixture]
[TestFixtureSource(typeof(GitRepoTests), GitRepoTests.ValidateWorkingTree)]
[Category(Categories.GitCommands)]
public class GitCommandsTests : GitRepoTests
{
Expand All @@ -26,7 +26,8 @@ public class GitCommandsTests : GitRepoTests
private static readonly string RenameFolderPathFrom = Path.Combine("GVFS", "GVFS.Common", "PrefetchPacks");
private static readonly string RenameFolderPathTo = Path.Combine("GVFS", "GVFS.Common", "PrefetchPacksRenamed");

public GitCommandsTests() : base(enlistmentPerTest: false)
public GitCommandsTests(ValidateWorkingTreeOptions validateWorkingTree)
: base(enlistmentPerTest: false, validateWorkingTree: validateWorkingTree)
{
}

Expand Down
45 changes: 38 additions & 7 deletions GVFS/GVFS.FunctionalTests/Tests/GitCommands/GitRepoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ namespace GVFS.FunctionalTests.Tests.GitCommands
[TestFixture]
public abstract class GitRepoTests
{
public const string ValidateWorkingTree = "WorkTreeValidation";

protected const string ConflictSourceBranch = "FunctionalTests/20170206_Conflict_Source";
protected const string ConflictTargetBranch = "FunctionalTests/20170206_Conflict_Target";
protected const string NoConflictSourceBranch = "FunctionalTests/20170209_NoConflict_Source";
Expand All @@ -23,13 +25,27 @@ public abstract class GitRepoTests
protected const string DeepDirectoryWithOneDifferentFile = "FunctionalTests/20181010_DeepFolderOneDifferentFile";

private bool enlistmentPerTest;
private bool validateWorkingTree;

public GitRepoTests(bool enlistmentPerTest)
public GitRepoTests(bool enlistmentPerTest, ValidateWorkingTreeOptions validateWorkingTree)
{
this.enlistmentPerTest = enlistmentPerTest;
this.validateWorkingTree = validateWorkingTree == ValidateWorkingTreeOptions.ValidateWorkingTree;
this.FileSystem = new SystemIORunner();
}

public enum ValidateWorkingTreeOptions
{
Invalid = 0,
DoNotValidateWorkingTree,
ValidateWorkingTree,
}

public static object[] WorkTreeValidation
{
get { return GVFSTestConfig.GitCommandTestWorkTreeValidation; }
}

public ControlGitRepo ControlGitRepo
{
get; private set;
Expand Down Expand Up @@ -74,8 +90,13 @@ public virtual void SetupForTest()
this.ValidateGitCommand("checkout " + this.ControlGitRepo.Commitish);

this.CheckHeadCommitTree();
this.Enlistment.RepoRoot.ShouldBeADirectory(this.FileSystem)
.WithDeepStructure(this.FileSystem, this.ControlGitRepo.RootPath);

if (this.validateWorkingTree)
{
this.Enlistment.RepoRoot.ShouldBeADirectory(this.FileSystem)
.WithDeepStructure(this.FileSystem, this.ControlGitRepo.RootPath);
}

this.ValidateGitCommand("status");
}

Expand All @@ -90,16 +111,26 @@ protected void TestValidationAndCleanup(bool ignoreCase = false)
try
{
this.CheckHeadCommitTree();
this.Enlistment.RepoRoot.ShouldBeADirectory(this.FileSystem)
.WithDeepStructure(this.FileSystem, this.ControlGitRepo.RootPath, ignoreCase: ignoreCase);

if (this.validateWorkingTree)
{
this.Enlistment.RepoRoot.ShouldBeADirectory(this.FileSystem)
.WithDeepStructure(this.FileSystem, this.ControlGitRepo.RootPath, ignoreCase: ignoreCase);
}

this.RunGitCommand("reset --hard -q HEAD");
this.RunGitCommand("clean -d -f -x");
this.ValidateGitCommand("checkout " + this.ControlGitRepo.Commitish);

this.CheckHeadCommitTree();
this.Enlistment.RepoRoot.ShouldBeADirectory(this.FileSystem)
.WithDeepStructure(this.FileSystem, this.ControlGitRepo.RootPath, ignoreCase: ignoreCase);

// If enlistmentPerTest is true we can always validate the working tree because
// this is the last place we'll use it
if (this.validateWorkingTree || this.enlistmentPerTest)
{
this.Enlistment.RepoRoot.ShouldBeADirectory(this.FileSystem)
.WithDeepStructure(this.FileSystem, this.ControlGitRepo.RootPath, ignoreCase: ignoreCase);
}
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

namespace GVFS.FunctionalTests.Tests.GitCommands
{
[TestFixture]
[TestFixtureSource(typeof(GitRepoTests), GitRepoTests.ValidateWorkingTree)]
[Category(Categories.GitCommands)]
[Category(Categories.MacTODO.M3)]
public class HashObjectTests : GitRepoTests
{
public HashObjectTests() : base(enlistmentPerTest: false)
public HashObjectTests(ValidateWorkingTreeOptions validateWorkingTree)
: base(enlistmentPerTest: false, validateWorkingTree: validateWorkingTree)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

namespace GVFS.FunctionalTests.Tests.GitCommands
{
[TestFixture]
[TestFixtureSource(typeof(GitRepoTests), GitRepoTests.ValidateWorkingTree)]
[Category(Categories.GitCommands)]
public class MergeConflictTests : GitRepoTests
{
public MergeConflictTests() : base(enlistmentPerTest: true)
public MergeConflictTests(ValidateWorkingTreeOptions validateWorkingTree)
: base(enlistmentPerTest: true, validateWorkingTree: validateWorkingTree)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace GVFS.FunctionalTests.Tests.GitCommands
{
[TestFixture]
[TestFixtureSource(typeof(GitRepoTests), GitRepoTests.ValidateWorkingTree)]
[Category(Categories.GitCommands)]
public class RebaseConflictTests : GitRepoTests
{
public RebaseConflictTests() : base(enlistmentPerTest: true)
public RebaseConflictTests(ValidateWorkingTreeOptions validateWorkingTree)
: base(enlistmentPerTest: true, validateWorkingTree: validateWorkingTree)
{
}

Expand Down
5 changes: 3 additions & 2 deletions GVFS/GVFS.FunctionalTests/Tests/GitCommands/RebaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace GVFS.FunctionalTests.Tests.GitCommands
{
[TestFixture]
[TestFixtureSource(typeof(GitRepoTests), GitRepoTests.ValidateWorkingTree)]
[Category(Categories.GitCommands)]
public class RebaseTests : GitRepoTests
{
public RebaseTests() : base(enlistmentPerTest: true)
public RebaseTests(ValidateWorkingTreeOptions validateWorkingTree)
: base(enlistmentPerTest: true, validateWorkingTree: validateWorkingTree)
{
}

Expand Down
7 changes: 4 additions & 3 deletions GVFS/GVFS.FunctionalTests/Tests/GitCommands/ResetHardTests.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using GVFS.FunctionalTests.Should;
using GVFS.FunctionalTests.Should;
using NUnit.Framework;

namespace GVFS.FunctionalTests.Tests.GitCommands
{
[TestFixture]
[TestFixtureSource(typeof(GitRepoTests), GitRepoTests.ValidateWorkingTree)]
[Category(Categories.GitCommands)]
public class ResetHardTests : GitRepoTests
{
private const string ResetHardCommand = "reset --hard";

public ResetHardTests() : base(enlistmentPerTest: true)
public ResetHardTests(ValidateWorkingTreeOptions validateWorkingTree)
: base(enlistmentPerTest: true, validateWorkingTree: validateWorkingTree)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@

namespace GVFS.FunctionalTests.Tests.GitCommands
{
[TestFixture]
[TestFixtureSource(typeof(GitRepoTests), GitRepoTests.ValidateWorkingTree)]
[Category(Categories.GitCommands)]
public class ResetMixedTests : GitRepoTests
{
public ResetMixedTests() : base(enlistmentPerTest: true)
public ResetMixedTests(ValidateWorkingTreeOptions validateWorkingTree)
: base(enlistmentPerTest: true, validateWorkingTree: validateWorkingTree)
{
}

Expand Down
5 changes: 3 additions & 2 deletions GVFS/GVFS.FunctionalTests/Tests/GitCommands/ResetSoftTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace GVFS.FunctionalTests.Tests.GitCommands
{
[TestFixture]
[TestFixtureSource(typeof(GitRepoTests), GitRepoTests.ValidateWorkingTree)]
[Category(Categories.GitCommands)]
public class ResetSoftTests : GitRepoTests
{
public ResetSoftTests() : base(enlistmentPerTest: true)
public ResetSoftTests(ValidateWorkingTreeOptions validateWorkingTree)
: base(enlistmentPerTest: true, validateWorkingTree: validateWorkingTree)
{
}

Expand Down
5 changes: 3 additions & 2 deletions GVFS/GVFS.FunctionalTests/Tests/GitCommands/RmTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

namespace GVFS.FunctionalTests.Tests.GitCommands
{
[TestFixture]
[TestFixtureSource(typeof(GitRepoTests), GitRepoTests.ValidateWorkingTree)]
public class RmTests : GitRepoTests
{
public RmTests() : base(enlistmentPerTest: false)
public RmTests(ValidateWorkingTreeOptions validateWorkingTree)
: base(enlistmentPerTest: false, validateWorkingTree: validateWorkingTree)
{
}

Expand Down
5 changes: 3 additions & 2 deletions GVFS/GVFS.FunctionalTests/Tests/GitCommands/StatusTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@

namespace GVFS.FunctionalTests.Tests.GitCommands
{
[TestFixture]
[TestFixtureSource(typeof(GitRepoTests), GitRepoTests.ValidateWorkingTree)]
[Category(Categories.GitCommands)]
public class StatusTests : GitRepoTests
{
public StatusTests() : base(enlistmentPerTest: true)
public StatusTests(ValidateWorkingTreeOptions validateWorkingTree)
: base(enlistmentPerTest: true, validateWorkingTree: validateWorkingTree)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

namespace GVFS.FunctionalTests.Tests.GitCommands
{
[TestFixture]
[TestFixtureSource(typeof(GitRepoTests), GitRepoTests.ValidateWorkingTree)]
[Category(Categories.GitCommands)]
public class UpdateIndexTests : GitRepoTests
{
public UpdateIndexTests() : base(enlistmentPerTest: true)
public UpdateIndexTests(ValidateWorkingTreeOptions validateWorkingTree)
: base(enlistmentPerTest: true, validateWorkingTree: validateWorkingTree)
{
}

Expand Down
Loading