diff --git a/LibGit2Sharp.Tests/ArchiveFixture.cs b/LibGit2Sharp.Tests/ArchiveFixture.cs index e070db85d..7253e2fe8 100644 --- a/LibGit2Sharp.Tests/ArchiveFixture.cs +++ b/LibGit2Sharp.Tests/ArchiveFixture.cs @@ -11,7 +11,8 @@ public class ArchiveFixture : BaseFixture [Fact] public void CanArchiveATree() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var tree = repo.Lookup("581f9824ecaf824221bd36edf5430f2739a7c4f5"); @@ -36,7 +37,8 @@ public void CanArchiveATree() [Fact] public void CanArchiveACommit() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var commit = repo.Lookup("4c062a6361ae6959e06292c1fa5e2822d9c96345"); @@ -61,7 +63,8 @@ public void CanArchiveACommit() [Fact] public void ArchivingANullTreeOrCommitThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.ObjectDatabase.Archive((Commit)null, null)); Assert.Throws(() => repo.ObjectDatabase.Archive((Tree)null, null)); diff --git a/LibGit2Sharp.Tests/ArchiveTarFixture.cs b/LibGit2Sharp.Tests/ArchiveTarFixture.cs index a59b23604..c1ae15783 100644 --- a/LibGit2Sharp.Tests/ArchiveTarFixture.cs +++ b/LibGit2Sharp.Tests/ArchiveTarFixture.cs @@ -11,7 +11,7 @@ public class ArchiveTarFixture : BaseFixture [Fact] public void CanArchiveACommitWithDirectoryAsTar() { - var path = CloneBareTestRepo(); + var path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { // This tests generates an archive of the bare test repo, and compares it with @@ -26,7 +26,7 @@ public void CanArchiveACommitWithDirectoryAsTar() var commit = repo.Lookup("4c062a6361ae6959e06292c1fa5e2822d9c96345"); var scd = BuildSelfCleaningDirectory(); - var archivePath = Path.Combine(scd.RootedDirectoryPath, Guid.NewGuid() + ".tar"); + var archivePath = Path.Combine(scd.RootedDirectoryPath, Path.GetRandomFileName() + ".tar"); Directory.CreateDirectory(scd.RootedDirectoryPath); repo.ObjectDatabase.Archive(commit, archivePath); diff --git a/LibGit2Sharp.Tests/AttributesFixture.cs b/LibGit2Sharp.Tests/AttributesFixture.cs index b6700becb..c9c4eb712 100644 --- a/LibGit2Sharp.Tests/AttributesFixture.cs +++ b/LibGit2Sharp.Tests/AttributesFixture.cs @@ -9,7 +9,7 @@ public class AttributesFixture : BaseFixture [Fact] public void StagingHonorsTheAttributesFiles() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { CreateAttributesFile(repo); diff --git a/LibGit2Sharp.Tests/BlameFixture.cs b/LibGit2Sharp.Tests/BlameFixture.cs index b0fcf77fe..b1915de13 100644 --- a/LibGit2Sharp.Tests/BlameFixture.cs +++ b/LibGit2Sharp.Tests/BlameFixture.cs @@ -22,7 +22,8 @@ private static void AssertCorrectHeadBlame(BlameHunkCollection blame) [Fact] public void CanBlameSimply() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { AssertCorrectHeadBlame(repo.Blame("README")); } @@ -31,7 +32,8 @@ public void CanBlameSimply() [Fact] public void CanBlameFromADifferentCommit() { - using (var repo = new Repository(MergedTestRepoWorkingDirPath)) + string path = SandboxMergedTestRepo(); + using (var repo = new Repository(path)) { // File doesn't exist at HEAD Assert.Throws(() => repo.Blame("ancestor-only.txt")); @@ -44,7 +46,8 @@ public void CanBlameFromADifferentCommit() [Fact] public void ValidatesLimits() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var blame = repo.Blame("README"); @@ -56,7 +59,8 @@ public void ValidatesLimits() [Fact] public void CanBlameFromVariousTypes() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { AssertCorrectHeadBlame(repo.Blame("README", new BlameOptions {StartingAt = "HEAD" })); AssertCorrectHeadBlame(repo.Blame("README", new BlameOptions {StartingAt = repo.Head })); @@ -68,7 +72,8 @@ public void CanBlameFromVariousTypes() [Fact] public void CanStopBlame() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { // $ git blame .\new.txt // 9fd738e8 (Scott Chacon 2010-05-24 10:19:19 -0700 1) my new file diff --git a/LibGit2Sharp.Tests/BlobFixture.cs b/LibGit2Sharp.Tests/BlobFixture.cs index 8e2722425..223a4d673 100644 --- a/LibGit2Sharp.Tests/BlobFixture.cs +++ b/LibGit2Sharp.Tests/BlobFixture.cs @@ -12,7 +12,8 @@ public class BlobFixture : BaseFixture [Fact] public void CanGetBlobAsText() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var blob = repo.Lookup("a8233120f6ad708f843d861ce2b7228ec4e3dec6"); @@ -30,7 +31,7 @@ public void CanGetBlobAsFilteredText(string autocrlf, string expectedText) { SkipIfNotSupported(autocrlf); - var path = CloneBareTestRepo(); + var path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { repo.Config.Set("core.autocrlf", autocrlf); @@ -52,7 +53,7 @@ public void CanGetBlobAsFilteredText(string autocrlf, string expectedText) [InlineData("utf-32", 20, "FF FE 00 00 31 00 00 00 32 00 00 00 33 00 00 00 34 00 00 00")] public void CanGetBlobAsTextWithVariousEncodings(string encodingName, int expectedContentBytes, string expectedUtf7Chars) { - var path = CloneStandardTestRepo(); + var path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { var bomFile = "bom.txt"; @@ -86,7 +87,8 @@ public void CanGetBlobAsTextWithVariousEncodings(string encodingName, int expect [Fact] public void CanGetBlobSize() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var blob = repo.Lookup("a8233120f6ad708f843d861ce2b7228ec4e3dec6"); Assert.Equal(10, blob.Size); @@ -96,7 +98,8 @@ public void CanGetBlobSize() [Fact] public void CanLookUpBlob() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var blob = repo.Lookup("a8233120f6ad708f843d861ce2b7228ec4e3dec6"); Assert.NotNull(blob); @@ -106,7 +109,8 @@ public void CanLookUpBlob() [Fact] public void CanReadBlobStream() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var blob = repo.Lookup("a8233120f6ad708f843d861ce2b7228ec4e3dec6"); @@ -129,7 +133,7 @@ public void CanReadBlobFilteredStream(string autocrlf, string expectedContent) { SkipIfNotSupported(autocrlf); - var path = CloneBareTestRepo(); + var path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { repo.Config.Set("core.autocrlf", autocrlf); @@ -153,7 +157,7 @@ public void CanReadBlobFilteredStreamOfUnmodifiedBinary() { var binaryContent = new byte[] { 0, 1, 2, 3, 4, 5 }; - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { using (var stream = new MemoryStream(binaryContent)) @@ -208,7 +212,8 @@ public void CanStageAFileGeneratedFromABlobContentStream() [Fact] public void CanTellIfTheBlobContentLooksLikeBinary() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var blob = repo.Lookup("a8233120f6ad708f843d861ce2b7228ec4e3dec6"); Assert.Equal(false, blob.IsBinary); diff --git a/LibGit2Sharp.Tests/BranchFixture.cs b/LibGit2Sharp.Tests/BranchFixture.cs index 486a43e27..03ea441a7 100644 --- a/LibGit2Sharp.Tests/BranchFixture.cs +++ b/LibGit2Sharp.Tests/BranchFixture.cs @@ -17,7 +17,7 @@ public class BranchFixture : BaseFixture [InlineData("Ångström")] public void CanCreateBranch(string name) { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { EnableRefLog(repo); @@ -50,7 +50,7 @@ public void CanCreateBranch(string name) [Fact] public void CanCreateAnUnbornBranch() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { // No branch named orphan @@ -85,7 +85,7 @@ public void CanCreateAnUnbornBranch() [Fact] public void CanCreateBranchUsingAbbreviatedSha() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { EnableRefLog(repo); @@ -108,7 +108,7 @@ public void CanCreateBranchUsingAbbreviatedSha() [InlineData("master")] public void CanCreateBranchFromImplicitHead(string headCommitOrBranchSpec) { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { EnableRefLog(repo); @@ -136,7 +136,7 @@ public void CanCreateBranchFromImplicitHead(string headCommitOrBranchSpec) [InlineData("master")] public void CanCreateBranchFromExplicitHead(string headCommitOrBranchSpec) { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { EnableRefLog(repo); @@ -157,7 +157,7 @@ public void CanCreateBranchFromExplicitHead(string headCommitOrBranchSpec) [Fact] public void CanCreateBranchFromCommit() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { EnableRefLog(repo); @@ -177,7 +177,7 @@ public void CanCreateBranchFromCommit() [Fact] public void CanCreateBranchFromRevparseSpec() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { EnableRefLog(repo); @@ -200,7 +200,7 @@ public void CanCreateBranchFromRevparseSpec() [InlineData("refs/tags/test")] public void CreatingABranchFromATagPeelsToTheCommit(string committish) { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { EnableRefLog(repo); @@ -220,7 +220,7 @@ public void CreatingABranchFromATagPeelsToTheCommit(string committish) [Fact] public void CreatingABranchTriggersTheCreationOfADirectReference() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Branch newBranch = repo.CreateBranch("clone-of-master"); @@ -238,7 +238,8 @@ public void CreatingABranchTriggersTheCreationOfADirectReference() [Fact] public void CreatingABranchFromANonCommitObjectThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { const string name = "sorry-dude-i-do-not-do-blobs-nor-trees"; Assert.Throws(() => repo.CreateBranch(name, "refs/tags/point_to_blob")); @@ -250,7 +251,8 @@ public void CreatingABranchFromANonCommitObjectThrows() [Fact] public void CreatingBranchWithUnknownNamedTargetThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Branches.Add("my_new_branch", "my_old_branch")); } @@ -259,7 +261,8 @@ public void CreatingBranchWithUnknownNamedTargetThrows() [Fact] public void CreatingBranchWithUnknownShaTargetThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Branches.Add("my_new_branch", Constants.UnknownSha)); Assert.Throws(() => repo.Branches.Add("my_new_branch", Constants.UnknownSha.Substring(0, 7))); @@ -269,7 +272,8 @@ public void CreatingBranchWithUnknownShaTargetThrows() [Fact] public void CreatingBranchWithBadParamsThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Branches.Add(null, repo.Head.CanonicalName)); Assert.Throws(() => repo.Branches.Add(string.Empty, repo.Head.CanonicalName)); @@ -282,7 +286,8 @@ public void CreatingBranchWithBadParamsThrows() [Fact] public void CanListAllBranches() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Equal(expectedBranches, SortedBranches(repo.Branches, b => b.Name)); @@ -293,7 +298,7 @@ public void CanListAllBranches() [Fact] public void CanListBranchesWithRemoteAndLocalBranchWithSameShortName() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { // Create a local branch with the same short name as a remote branch. @@ -312,7 +317,8 @@ public void CanListBranchesWithRemoteAndLocalBranchWithSameShortName() [Fact] public void CanListAllBranchesWhenGivenWorkingDir() { - using (var repo = new Repository(StandardTestRepoWorkingDirPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { var expectedWdBranches = new[] { @@ -328,7 +334,8 @@ public void CanListAllBranchesWhenGivenWorkingDir() [Fact] public void CanListAllBranchesIncludingRemoteRefs() { - using (var repo = new Repository(StandardTestRepoPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { var expectedBranchesIncludingRemoteRefs = new[] { @@ -352,7 +359,8 @@ public void CanListAllBranchesIncludingRemoteRefs() [Fact] public void CanResolveRemote() { - using (var repo = new Repository(StandardTestRepoPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { Branch master = repo.Branches["master"]; Assert.Equal(repo.Network.Remotes["origin"], master.Remote); @@ -362,7 +370,8 @@ public void CanResolveRemote() [Fact] public void RemoteAndUpstreamBranchCanonicalNameForNonTrackingBranchIsNull() { - using (var repo = new Repository(StandardTestRepoPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { Branch test = repo.Branches["i-do-numbers"]; Assert.Null(test.Remote); @@ -374,7 +383,8 @@ public void RemoteAndUpstreamBranchCanonicalNameForNonTrackingBranchIsNull() public void QueryRemoteForLocalTrackingBranch() { // There is not a Remote to resolve for a local tracking branch. - using (var repo = new Repository(StandardTestRepoPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { Branch trackLocal = repo.Branches["track-local"]; Assert.Null(trackLocal.Remote); @@ -384,7 +394,8 @@ public void QueryRemoteForLocalTrackingBranch() [Fact] public void QueryUpstreamBranchCanonicalNameForLocalTrackingBranch() { - using (var repo = new Repository(StandardTestRepoPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { Branch trackLocal = repo.Branches["track-local"]; Assert.Equal("refs/heads/master", trackLocal.UpstreamBranchCanonicalName); @@ -394,7 +405,8 @@ public void QueryUpstreamBranchCanonicalNameForLocalTrackingBranch() [Fact] public void QueryRemoteForRemoteBranch() { - using (var repo = new Repository(StandardTestRepoPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { var master = repo.Branches["origin/master"]; Assert.Equal(repo.Network.Remotes["origin"], master.Remote); @@ -404,7 +416,7 @@ public void QueryRemoteForRemoteBranch() [Fact] public void QueryUnresolvableRemoteForRemoteBranch() { - var path = CloneStandardTestRepo(); + var path = SandboxStandardTestRepo(); var fetchRefSpecs = new string[] { "+refs/heads/notfound/*:refs/remotes/origin/notfound/*" }; @@ -429,7 +441,7 @@ public void QueryUnresolvableRemoteForRemoteBranch() [Fact] public void QueryAmbigousRemoteForRemoteBranch() { - var path = CloneStandardTestRepo(); + var path = SandboxStandardTestRepo(); var fetchRefSpec = "+refs/heads/*:refs/remotes/origin/*"; var url = "http://github.com/libgit2/TestGitRepository"; @@ -452,7 +464,8 @@ public void QueryAmbigousRemoteForRemoteBranch() [Fact] public void CanLookupABranchByItsCanonicalName() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Branch branch = repo.Branches["refs/heads/br2"]; Assert.NotNull(branch); @@ -470,7 +483,8 @@ public void CanLookupABranchByItsCanonicalName() [Fact] public void CanLookupLocalBranch() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Branch master = repo.Branches["master"]; Assert.NotNull(master); @@ -485,7 +499,7 @@ public void CanLookupLocalBranch() [Fact] public void CanLookupABranchWhichNameIsMadeOfNon7BitsAsciiCharacters() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { const string name = "Ångström"; @@ -501,7 +515,8 @@ public void CanLookupABranchWhichNameIsMadeOfNon7BitsAsciiCharacters() [Fact] public void LookingOutABranchByNameWithBadParamsThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Branch branch; Assert.Throws(() => branch = repo.Branches[null]); @@ -539,7 +554,7 @@ public void CanGetInformationFromUnbornBranch() [Fact] public void CanGetTrackingInformationFromBranchSharingNoHistoryWithItsTrackedBranch() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Branch master = repo.Branches["master"]; @@ -565,7 +580,7 @@ public void CanGetTrackingInformationFromBranchSharingNoHistoryWithItsTrackedBra [Fact] public void TrackingInformationIsEmptyForBranchTrackingPrunedRemoteBranch() { - var path = CloneStandardTestRepo(); + var path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { const string remoteRef = "refs/remotes/origin/master"; @@ -587,7 +602,8 @@ public void TrackingInformationIsEmptyForBranchTrackingPrunedRemoteBranch() [Fact] public void TrackingInformationIsEmptyForNonTrackingBranch() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Branch branch = repo.Branches["test"]; Assert.False(branch.IsTracking); @@ -603,7 +619,8 @@ public void TrackingInformationIsEmptyForNonTrackingBranch() [Fact] public void CanGetTrackingInformationForTrackingBranch() { - using (var repo = new Repository(StandardTestRepoPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { Branch master = repo.Branches["master"]; Assert.True(master.IsTracking); @@ -619,7 +636,8 @@ public void CanGetTrackingInformationForTrackingBranch() [Fact] public void CanGetTrackingInformationForLocalTrackingBranch() { - using (var repo = new Repository(StandardTestRepoPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { var branch = repo.Branches["track-local"]; Assert.True(branch.IsTracking); @@ -635,7 +653,8 @@ public void CanGetTrackingInformationForLocalTrackingBranch() [Fact] public void RenamingARemoteTrackingBranchThrows() { - using (var repo = new Repository(StandardTestRepoPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { Branch master = repo.Branches["refs/remotes/origin/master"]; Assert.True(master.IsRemote); @@ -647,7 +666,8 @@ public void RenamingARemoteTrackingBranchThrows() [Fact] public void CanWalkCommitsFromAnotherBranch() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Branch master = repo.Branches["test"]; Assert.Equal(2, master.Commits.Count()); @@ -660,7 +680,7 @@ public void CanSetTrackedBranch() const string testBranchName = "branchToSetUpstreamInfoFor"; const string trackedBranchName = "refs/remotes/origin/master"; - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Branch branch = repo.CreateBranch(testBranchName); @@ -692,7 +712,7 @@ public void SetTrackedBranchForUnreasolvableRemoteThrows() const string trackedBranchName = "refs/remotes/origin/master"; var fetchRefSpecs = new string[] { "+refs/heads/notfound/*:refs/remotes/origin/notfound/*" }; - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { // Modify the fetch spec so that the remote for the remote-tracking branch @@ -720,7 +740,7 @@ public void CanSetUpstreamBranch() const string trackedBranchName = "refs/remotes/origin/master"; const string remoteName = "origin"; - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Branch branch = repo.CreateBranch(testBranchName); @@ -750,7 +770,7 @@ public void CanSetLocalTrackedBranch() const string testBranchName = "branchToSetUpstreamInfoFor"; const string localTrackedBranchName = "refs/heads/master"; - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Branch branch = repo.CreateBranch(testBranchName); @@ -788,7 +808,7 @@ public void CanUnsetTrackedBranch() const string testBranchName = "branchToSetUpstreamInfoFor"; const string trackedBranchName = "refs/remotes/origin/master"; - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Branch branch = repo.CreateBranch(testBranchName); @@ -813,7 +833,8 @@ public void CanUnsetTrackedBranch() [Fact] public void CanWalkCommitsFromBranch() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Branch master = repo.Branches["master"]; Assert.Equal(7, master.Commits.Count()); @@ -822,7 +843,7 @@ public void CanWalkCommitsFromBranch() private void AssertRemoval(string branchName, bool isRemote, bool shouldPreviouslyAssertExistence) { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { if (shouldPreviouslyAssertExistence) @@ -849,7 +870,7 @@ public void CanRemoveAnExistingNamedBranch(string branchName, bool isRemote) [InlineData("origin/br2")] public void CanRemoveAnExistingBranch(string branchName) { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Branch curBranch = repo.Branches[branchName]; @@ -871,7 +892,8 @@ public void CanRemoveANonExistingBranch(string branchName, bool isRemote) [Fact] public void RemovingABranchWhichIsTheCurrentHeadThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Branches.Remove(repo.Head.Name)); } @@ -880,7 +902,8 @@ public void RemovingABranchWhichIsTheCurrentHeadThrows() [Fact] public void RemovingABranchWithBadParamsThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Branches.Remove(string.Empty)); Assert.Throws(() => repo.Branches.Remove(null)); @@ -890,7 +913,8 @@ public void RemovingABranchWithBadParamsThrows() [Fact] public void OnlyOneBranchIsTheHead() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Branch head = null; @@ -919,7 +943,7 @@ public void OnlyOneBranchIsTheHead() [Fact] public void TwoBranchesPointingAtTheSameCommitAreNotBothCurrent() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Branch master = repo.Branches["refs/heads/master"]; @@ -932,7 +956,7 @@ public void TwoBranchesPointingAtTheSameCommitAreNotBothCurrent() [Fact] public void CanRenameABranch() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { EnableRefLog(repo); @@ -957,7 +981,8 @@ public void CanRenameABranch() [Fact] public void BlindlyRenamingABranchOverAnExistingOneThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Branches.Rename("br2", "test")); } @@ -966,7 +991,7 @@ public void BlindlyRenamingABranchOverAnExistingOneThrows() [Fact] public void CanRenameABranchWhileOverwritingAnExistingOne() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { EnableRefLog(repo); @@ -998,7 +1023,7 @@ public void CanRenameABranchWhileOverwritingAnExistingOne() [Fact] public void DetachedHeadIsNotATrackingBranch() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Reset(ResetMode.Hard); @@ -1068,7 +1093,8 @@ public void TrackedBranchExistsFromDefaultConfigInEmptyClone() [Fact] public void RemoteBranchesDoNotTrackAnything() { - using (var repo = new Repository(StandardTestRepoPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { var branches = repo.Branches.Where(b => b.IsRemote); @@ -1095,7 +1121,7 @@ private static T[] SortedBranches(IEnumerable branches, Func(() => repo.Checkout(repo.Branches["refs/heads/test"])); Assert.Throws(() => repo.Checkout("refs/heads/test")); @@ -379,7 +380,8 @@ public void CheckingOutAgainstAnUnbornBranchThrows() [Fact] public void CheckingOutANonExistingBranchThrows() { - using (var repo = new Repository(StandardTestRepoWorkingDirPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Checkout("i-do-not-exist")); } @@ -388,7 +390,8 @@ public void CheckingOutANonExistingBranchThrows() [Fact] public void CheckingOutABranchWithBadParamsThrows() { - using (var repo = new Repository(StandardTestRepoWorkingDirPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Checkout(string.Empty)); Assert.Throws(() => repo.Checkout(default(Branch))); @@ -699,7 +702,7 @@ public void CheckoutBranchSnapshot() [InlineData("origin/master")] public void CheckingOutRemoteBranchResultsInDetachedHead(string remoteBranchSpec) { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Branch master = repo.Branches["master"]; @@ -719,7 +722,7 @@ public void CheckingOutRemoteBranchResultsInDetachedHead(string remoteBranchSpec [Fact] public void CheckingOutABranchDoesNotAlterBinaryFiles() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { // $ git hash-object square-logo.png @@ -748,7 +751,7 @@ public void CheckingOutABranchDoesNotAlterBinaryFiles() [InlineData("e90810^{}")] public void CheckoutFromDetachedHead(string commitPointer) { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { // Set the working directory to the current head @@ -774,7 +777,7 @@ public void CheckoutFromDetachedHead(string commitPointer) [Fact] public void CheckoutBranchFromDetachedHead() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { // Set the working directory to the current head @@ -799,7 +802,7 @@ public void CheckoutBranchFromDetachedHead() [InlineData("heads/master", "refs/heads/master")] public void CheckoutBranchByShortNameAttachesTheHead(string shortBranchName, string referenceName) { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { // Set the working directory to the current head @@ -820,7 +823,7 @@ public void CheckoutBranchByShortNameAttachesTheHead(string shortBranchName, str [Fact] public void CheckoutPreviousCheckedOutBranch() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { // Set the working directory to the current head @@ -842,7 +845,7 @@ public void CheckoutPreviousCheckedOutBranch() [Fact] public void CheckoutCurrentReference() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Branch master = repo.Branches["master"]; @@ -889,7 +892,8 @@ public void CheckoutCurrentReference() [Fact] public void CheckoutLowerCasedHeadThrows() { - using (var repo = new Repository(StandardTestRepoWorkingDirPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Checkout("head")); } @@ -898,7 +902,7 @@ public void CheckoutLowerCasedHeadThrows() [Fact] public void CanCheckoutAttachedHead() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Assert.False(repo.Info.IsHeadDetached); @@ -914,7 +918,7 @@ public void CanCheckoutAttachedHead() [Fact] public void CanCheckoutDetachedHead() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Checkout(repo.Head.Tip.Sha); @@ -936,7 +940,7 @@ public void CanCheckoutDetachedHead() [InlineData("i-do-numbers", "diff-test-cases", "numbers.txt", FileStatus.Staged)] public void CanCheckoutPath(string originalBranch, string checkoutFrom, string path, FileStatus expectedStatus) { - string repoPath = CloneStandardTestRepo(); + string repoPath = SandboxStandardTestRepo(); using (var repo = new Repository(repoPath)) { // Set the working directory to the current head @@ -955,7 +959,7 @@ public void CanCheckoutPath(string originalBranch, string checkoutFrom, string p [Fact] public void CanCheckoutPaths() { - string repoPath = CloneStandardTestRepo(); + string repoPath = SandboxStandardTestRepo(); var checkoutPaths = new[] { "numbers.txt", "super-file.txt" }; using (var repo = new Repository(repoPath)) @@ -976,7 +980,7 @@ public void CanCheckoutPaths() [Fact] public void CannotCheckoutPathsWithEmptyOrNullPathArgument() { - string repoPath = CloneStandardTestRepo(); + string repoPath = SandboxStandardTestRepo(); using (var repo = new Repository(repoPath)) { @@ -999,7 +1003,7 @@ public void CannotCheckoutPathsWithEmptyOrNullPathArgument() [InlineData("1.txt")] public void CanCheckoutPathFromCurrentBranch(string fileName) { - string repoPath = CloneStandardTestRepo(); + string repoPath = SandboxStandardTestRepo(); using (var repo = new Repository(repoPath)) { diff --git a/LibGit2Sharp.Tests/CherryPickFixture.cs b/LibGit2Sharp.Tests/CherryPickFixture.cs index 7afb3f033..be08684cf 100644 --- a/LibGit2Sharp.Tests/CherryPickFixture.cs +++ b/LibGit2Sharp.Tests/CherryPickFixture.cs @@ -14,7 +14,7 @@ public class CherryPickFixture : BaseFixture [InlineData(false)] public void CanCherryPick(bool fromDetachedHead) { - string path = CloneMergeTestRepo(); + string path = SandboxMergeTestRepo(); using (var repo = new Repository(path)) { if (fromDetachedHead) @@ -42,7 +42,7 @@ public void CherryPickWithConflictDoesNotCommit() const string secondBranchFileName = "second branch file.txt"; const string sharedBranchFileName = "first+second branch file.txt"; - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { var firstBranch = repo.CreateBranch("FirstBranch"); @@ -83,7 +83,7 @@ public void CanSpecifyConflictFileStrategy(CheckoutFileConflictStrategy conflict const string conflictFile = "a.txt"; const string conflictBranchName = "conflicts"; - string path = CloneMergeTestRepo(); + string path = SandboxMergeTestRepo(); using (var repo = new Repository(path)) { Branch branch = repo.Branches[conflictBranchName]; diff --git a/LibGit2Sharp.Tests/CleanFixture.cs b/LibGit2Sharp.Tests/CleanFixture.cs index 358000b94..f674285c6 100644 --- a/LibGit2Sharp.Tests/CleanFixture.cs +++ b/LibGit2Sharp.Tests/CleanFixture.cs @@ -9,7 +9,7 @@ public class CleanFixture : BaseFixture [Fact] public void CanCleanWorkingDirectory() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { // Verify that there are the expected number of entries and untracked files @@ -27,7 +27,8 @@ public void CanCleanWorkingDirectory() [Fact] public void CannotCleanABareRepository() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.RemoveUntrackedFiles()); } diff --git a/LibGit2Sharp.Tests/CloneFixture.cs b/LibGit2Sharp.Tests/CloneFixture.cs index ca448acd2..d291ddcdc 100644 --- a/LibGit2Sharp.Tests/CloneFixture.cs +++ b/LibGit2Sharp.Tests/CloneFixture.cs @@ -79,7 +79,7 @@ private void AssertLocalClone(string url, string path = null, bool isCloningAnEm [Fact] public void CanCloneALocalRepositoryFromALocalUri() { - var uri = new Uri(BareTestRepoPath); + var uri = new Uri(Path.GetFullPath(BareTestRepoPath)); AssertLocalClone(uri.AbsoluteUri, BareTestRepoPath); } @@ -92,7 +92,7 @@ public void CanCloneALocalRepositoryFromAStandardPath() [Fact] public void CanCloneALocalRepositoryFromANewlyCreatedTemporaryPath() { - var path = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString().Substring(0, 8)); + var path = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); SelfCleaningDirectory scd = BuildSelfCleaningDirectory(path); Repository.Init(scd.DirectoryPath); AssertLocalClone(scd.DirectoryPath, isCloningAnEmptyRepository: true); diff --git a/LibGit2Sharp.Tests/CommitAncestorFixture.cs b/LibGit2Sharp.Tests/CommitAncestorFixture.cs index fe83c1117..6ea6176b6 100644 --- a/LibGit2Sharp.Tests/CommitAncestorFixture.cs +++ b/LibGit2Sharp.Tests/CommitAncestorFixture.cs @@ -35,7 +35,8 @@ public class CommitAncestorFixture : BaseFixture [InlineData(null, "be3563a", "-")] public void FindCommonAncestorForTwoCommits(string result, string sha1, string sha2) { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var first = sha1 == "-" ? CreateOrphanedCommit(repo) : repo.Lookup(sha1); var second = sha2 == "-" ? CreateOrphanedCommit(repo) : repo.Lookup(sha2); @@ -65,7 +66,8 @@ public void FindCommonAncestorForTwoCommits(string result, string sha1, string s [InlineData(null, new[] { "4c062a6", "-" }, MergeBaseFindingStrategy.Standard)] public void FindCommonAncestorForCommitsAsEnumerable(string result, string[] shas, MergeBaseFindingStrategy strategy) { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var commits = shas.Select(sha => sha == "-" ? CreateOrphanedCommit(repo) : repo.Lookup(sha)).ToArray(); @@ -88,7 +90,8 @@ public void FindCommonAncestorForCommitsAsEnumerable(string result, string[] sha [InlineData("0000000", "4c062a6")] public void FindCommonAncestorForTwoCommitsThrows(string sha1, string sha2) { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var first = repo.Lookup(sha1); var second = repo.Lookup(sha2); @@ -104,7 +107,8 @@ public void FindCommonAncestorForTwoCommitsThrows(string sha1, string sha2) [InlineData(new[] { "4c062a6", "be3563a", "000000" }, MergeBaseFindingStrategy.Standard)] public void FindCommonAncestorForCommitsAsEnumerableThrows(string[] shas, MergeBaseFindingStrategy strategy) { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var commits = shas.Select(sha => sha == "-" ? CreateOrphanedCommit(repo) : repo.Lookup(sha)).ToArray(); diff --git a/LibGit2Sharp.Tests/CommitFixture.cs b/LibGit2Sharp.Tests/CommitFixture.cs index a4d7eca44..50a099dda 100644 --- a/LibGit2Sharp.Tests/CommitFixture.cs +++ b/LibGit2Sharp.Tests/CommitFixture.cs @@ -17,7 +17,8 @@ public class CommitFixture : BaseFixture [Fact] public void CanCountCommits() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Equal(7, repo.Commits.Count()); } @@ -26,7 +27,7 @@ public void CanCountCommits() [Fact] public void CanCorrectlyCountCommitsWhenSwitchingToAnotherBranch() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { // Hard reset and then remove untracked files @@ -47,7 +48,8 @@ public void CanCorrectlyCountCommitsWhenSwitchingToAnotherBranch() public void CanEnumerateCommits() { int count = 0; - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { foreach (Commit commit in repo.Commits) { @@ -61,7 +63,7 @@ public void CanEnumerateCommits() [Fact] public void CanEnumerateCommitsInDetachedHeadState() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { ObjectId parentOfHead = repo.Head.Tip.Parents.First().Id; @@ -76,7 +78,8 @@ public void CanEnumerateCommitsInDetachedHeadState() [Fact] public void DefaultOrderingWhenEnumeratingCommitsIsTimeBased() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Equal(CommitSortStrategies.Time, repo.Commits.SortedBy); } @@ -86,7 +89,8 @@ public void DefaultOrderingWhenEnumeratingCommitsIsTimeBased() public void CanEnumerateCommitsFromSha() { int count = 0; - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { foreach (Commit commit in repo.Commits.QueryBy(new CommitFilter { Since = "a4a7dce85cf63874e984719f4fdd239f5145052f" })) { @@ -100,7 +104,8 @@ public void CanEnumerateCommitsFromSha() [Fact] public void QueryingTheCommitHistoryWithUnknownShaOrInvalidEntryPointThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { Since = Constants.UnknownSha }).Count()); Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { Since = "refs/heads/deadbeef" }).Count()); @@ -111,7 +116,7 @@ public void QueryingTheCommitHistoryWithUnknownShaOrInvalidEntryPointThrows() [Fact] public void QueryingTheCommitHistoryFromACorruptedReferenceThrows() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { CreateCorruptedDeadBeefHead(repo.Info.Path); @@ -124,7 +129,8 @@ public void QueryingTheCommitHistoryFromACorruptedReferenceThrows() [Fact] public void QueryingTheCommitHistoryWithBadParamsThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { Since = string.Empty })); Assert.Throws(() => repo.Commits.QueryBy(new CommitFilter { Since = null })); @@ -139,7 +145,8 @@ public void CanEnumerateCommitsWithReverseTimeSorting() reversedShas.Reverse(); int count = 0; - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { foreach (Commit commit in repo.Commits.QueryBy(new CommitFilter { @@ -158,7 +165,8 @@ public void CanEnumerateCommitsWithReverseTimeSorting() [Fact] public void CanEnumerateCommitsWithReverseTopoSorting() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { List commits = repo.Commits.QueryBy(new CommitFilter { @@ -192,7 +200,8 @@ public void CanSimplifyByFirstParent() [Fact] public void CanGetParentsCount() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Equal(1, repo.Commits.First().Parents.Count()); } @@ -202,7 +211,8 @@ public void CanGetParentsCount() public void CanEnumerateCommitsWithTimeSorting() { int count = 0; - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { foreach (Commit commit in repo.Commits.QueryBy(new CommitFilter { @@ -221,7 +231,8 @@ public void CanEnumerateCommitsWithTimeSorting() [Fact] public void CanEnumerateCommitsWithTopoSorting() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { List commits = repo.Commits.QueryBy(new CommitFilter { @@ -255,7 +266,7 @@ public void CanEnumerateFromHead() [Fact] public void CanEnumerateFromDetachedHead() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repoClone = new Repository(path)) { // Hard reset and then remove untracked files @@ -364,7 +375,7 @@ public void CanEnumerateCommitsFromATagAnnotation() CanEnumerateCommitsFromATag(t => t.Annotation); } - private static void CanEnumerateCommitsFromATag(Func transformer) + private void CanEnumerateCommitsFromATag(Func transformer) { AssertEnumerationOfCommits( repo => new CommitFilter { Since = transformer(repo.Tags["test"]) }, @@ -400,7 +411,7 @@ public void CanEnumerateCommitsFromATagWhichPointsToABlob() [Fact] public void CanEnumerateCommitsFromATagWhichPointsToATree() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { string headTreeSha = repo.Head.Tip.Tree.Sha; @@ -413,9 +424,10 @@ public void CanEnumerateCommitsFromATagWhichPointsToATree() } } - private static void AssertEnumerationOfCommits(Func filterBuilder, IEnumerable abbrevIds) + private void AssertEnumerationOfCommits(Func filterBuilder, IEnumerable abbrevIds) { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { AssertEnumerationOfCommitsInRepo(repo, filterBuilder, abbrevIds); } @@ -433,7 +445,8 @@ private static void AssertEnumerationOfCommitsInRepo(IRepository repo, Func(sha); Assert.Equal("testing\n", commit.Message); @@ -445,7 +458,8 @@ public void CanLookupCommitGeneric() [Fact] public void CanReadCommitData() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { GitObject obj = repo.Lookup(sha); Assert.NotNull(obj); @@ -476,7 +490,8 @@ public void CanReadCommitData() [Fact] public void CanReadCommitWithMultipleParents() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var commit = repo.Lookup("a4a7dce85cf63874e984719f4fdd239f5145052f"); Assert.Equal(2, commit.Parents.Count()); @@ -486,7 +501,8 @@ public void CanReadCommitWithMultipleParents() [Fact] public void CanDirectlyAccessABlobOfTheCommit() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var commit = repo.Lookup("4c062a6"); @@ -500,7 +516,8 @@ public void CanDirectlyAccessABlobOfTheCommit() [Fact] public void CanDirectlyAccessATreeOfTheCommit() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var commit = repo.Lookup("4c062a6"); @@ -512,7 +529,8 @@ public void CanDirectlyAccessATreeOfTheCommit() [Fact] public void DirectlyAccessingAnUnknownTreeEntryOfTheCommitReturnsNull() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var commit = repo.Lookup("4c062a6"); @@ -575,7 +593,7 @@ public void CanCommitWithSignatureFromConfig() [Fact] public void CommitParentsAreMergeHeads() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Reset(ResetMode.Hard, "c47800"); @@ -786,7 +804,7 @@ public void CanAmendARootCommit() [Fact] public void CanAmendACommitWithMoreThanOneParent() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { var mergedCommit = repo.Lookup("be3563a"); @@ -813,7 +831,7 @@ public void CanAmendACommitWithMoreThanOneParent() private static void CreateAndStageANewFile(IRepository repo) { - string relativeFilepath = string.Format("new-file-{0}.txt", Guid.NewGuid()); + string relativeFilepath = string.Format("new-file-{0}.txt", Path.GetRandomFileName()); Touch(repo.Info.WorkingDirectory, relativeFilepath, "brand new content\n"); repo.Stage(relativeFilepath); } @@ -842,7 +860,7 @@ public void CanNotAmendAnEmptyRepository() [Fact] public void CanRetrieveChildrenOfASpecificCommit() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { const string parentSha = "5b5b025afb0b4c913b4c338a42934a3863bf3644"; @@ -874,7 +892,7 @@ from p in c.Parents [Fact] public void CanCorrectlyDistinguishAuthorFromCommitter() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { var author = new Signature("Wilbert van Dolleweerd", "getit@xs4all.nl", @@ -914,7 +932,7 @@ public void CanCommitOnOrphanedBranch() [Fact] public void CanNotCommitAnEmptyCommit() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Reset(ResetMode.Hard); @@ -927,7 +945,7 @@ public void CanNotCommitAnEmptyCommit() [Fact] public void CanCommitAnEmptyCommitWhenForced() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Reset(ResetMode.Hard); @@ -941,7 +959,7 @@ public void CanCommitAnEmptyCommitWhenForced() [Fact] public void CanNotAmendAnEmptyCommit() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Reset(ResetMode.Hard); @@ -958,7 +976,7 @@ public void CanNotAmendAnEmptyCommit() [Fact] public void CanAmendAnEmptyCommitWhenForced() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Reset(ResetMode.Hard); @@ -976,7 +994,7 @@ public void CanAmendAnEmptyCommitWhenForced() [Fact] public void CanCommitAnEmptyCommitWhenMerging() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Reset(ResetMode.Hard); @@ -997,7 +1015,7 @@ public void CanCommitAnEmptyCommitWhenMerging() [Fact] public void CanAmendAnEmptyMergeCommit() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Reset(ResetMode.Hard); diff --git a/LibGit2Sharp.Tests/ConfigurationFixture.cs b/LibGit2Sharp.Tests/ConfigurationFixture.cs index ad085a5a0..edce94932 100644 --- a/LibGit2Sharp.Tests/ConfigurationFixture.cs +++ b/LibGit2Sharp.Tests/ConfigurationFixture.cs @@ -46,7 +46,7 @@ private static void AssertValueInGlobalConfigFile(string regex) [Fact] public void CanUnsetAnEntryFromTheLocalConfiguration() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Assert.Null(repo.Config.Get("unittests.boolsetting")); @@ -67,7 +67,8 @@ public void CanUnsetAnEntryFromTheGlobalConfiguration() var options = BuildFakeConfigs(scd); - using (var repo = new Repository(BareTestRepoPath, options)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path, options)) { Assert.True(repo.Config.HasConfig(ConfigurationLevel.Global)); Assert.Equal(42, repo.Config.Get("Wow.Man-I-am-totally-global").Value); @@ -83,7 +84,8 @@ public void CanUnsetAnEntryFromTheGlobalConfiguration() [Fact] public void CanReadBooleanValue() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.True(repo.Config.Get("core.ignorecase").Value); Assert.True(repo.Config.GetValueOrDefault("core.ignorecase")); @@ -97,7 +99,8 @@ public void CanReadBooleanValue() [Fact] public void CanReadIntValue() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Equal(2, repo.Config.Get("unittests.intsetting").Value); Assert.Equal(2, repo.Config.GetValueOrDefault("unittests.intsetting")); @@ -112,7 +115,8 @@ public void CanReadIntValue() [Fact] public void CanReadLongValue() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Equal(15234, repo.Config.Get("unittests.longsetting").Value); Assert.Equal(15234, repo.Config.GetValueOrDefault("unittests.longsetting")); @@ -126,7 +130,8 @@ public void CanReadLongValue() [Fact] public void CanReadStringValue() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Equal("+refs/heads/*:refs/remotes/origin/*", repo.Config.Get("remote.origin.fetch").Value); Assert.Equal("+refs/heads/*:refs/remotes/origin/*", repo.Config.Get("remote", "origin", "fetch").Value); @@ -168,7 +173,8 @@ public void CanEnumerateGlobalConfig() string configPath = CreateConfigurationWithDummyUser(Constants.Signature); var options = new RepositoryOptions { GlobalConfigurationLocation = configPath }; - using (var repo = new Repository(StandardTestRepoPath, options)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path, options)) { var entry = repo.Config.FirstOrDefault>(e => e.Key == "user.name"); Assert.NotNull(entry); @@ -179,7 +185,8 @@ public void CanEnumerateGlobalConfig() [Fact] public void CanEnumerateLocalConfig() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { var entry = repo.Config.FirstOrDefault>(e => e.Key == "core.ignorecase"); Assert.NotNull(entry); @@ -190,7 +197,8 @@ public void CanEnumerateLocalConfig() [Fact] public void CanEnumerateLocalConfigContainingAKeyWithNoValue() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var entry = repo.Config .Single>(c => c.Level == ConfigurationLevel.Local && c.Key == "core.pager"); @@ -202,7 +210,8 @@ public void CanEnumerateLocalConfigContainingAKeyWithNoValue() [Fact] public void CanFindInLocalConfig() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { var matches = repo.Config.Find("unit"); @@ -218,7 +227,8 @@ public void CanFindInGlobalConfig() string configPath = CreateConfigurationWithDummyUser(Constants.Signature); var options = new RepositoryOptions { GlobalConfigurationLocation = configPath }; - using (var repo = new Repository(StandardTestRepoPath, options)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path, options)) { var matches = repo.Config.Find(@"\.name", ConfigurationLevel.Global); @@ -231,7 +241,7 @@ public void CanFindInGlobalConfig() [Fact] public void CanSetBooleanValue() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Config.Set("unittests.boolsetting", true); @@ -252,7 +262,7 @@ public void SettingLocalConfigurationOutsideAReposThrows() [Fact] public void CanSetIntValue() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Config.Set("unittests.intsetting", 3); @@ -264,7 +274,7 @@ public void CanSetIntValue() [Fact] public void CanSetLongValue() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Config.Set("unittests.longsetting", (long)451); @@ -276,7 +286,7 @@ public void CanSetLongValue() [Fact] public void CanSetStringValue() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Config.Set("unittests.stringsetting", "val"); @@ -288,7 +298,7 @@ public void CanSetStringValue() [Fact] public void CanSetAndReadUnicodeStringValue() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Config.Set("unittests.stringsetting", "Juliën"); @@ -310,7 +320,8 @@ public void CanSetAndReadUnicodeStringValue() [Fact] public void ReadingUnsupportedTypeThrows() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Config.Get("unittests.setting")); Assert.Throws(() => repo.Config.Get("unittests.setting")); @@ -320,7 +331,8 @@ public void ReadingUnsupportedTypeThrows() [Fact] public void ReadingValueThatDoesntExistReturnsNull() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Null(repo.Config.Get("unittests.ghostsetting")); Assert.Null(repo.Config.Get("unittests.ghostsetting")); @@ -332,7 +344,8 @@ public void ReadingValueThatDoesntExistReturnsNull() [Fact] public void SettingUnsupportedTypeThrows() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Config.Set("unittests.setting", (short)123)); Assert.Throws(() => repo.Config.Set("unittests.setting", repo.Config)); @@ -346,7 +359,7 @@ public void CanGetAnEntryFromASpecificStore() var options = BuildFakeConfigs(scd); - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path, options)) { Assert.True(repo.Config.HasConfig(ConfigurationLevel.Local)); @@ -371,7 +384,8 @@ public void CanTellIfASpecificStoreContainsAKey() var options = BuildFakeConfigs(scd); - using (var repo = new Repository(BareTestRepoPath, options)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path, options)) { Assert.True(repo.Config.HasConfig(ConfigurationLevel.System)); diff --git a/LibGit2Sharp.Tests/ConflictFixture.cs b/LibGit2Sharp.Tests/ConflictFixture.cs index 148081c4c..af1663676 100644 --- a/LibGit2Sharp.Tests/ConflictFixture.cs +++ b/LibGit2Sharp.Tests/ConflictFixture.cs @@ -66,7 +66,7 @@ private static List RenameConflictData public void CanResolveConflictsByRemovingFromTheIndex( bool removeFromWorkdir, string filename, bool existsBeforeRemove, bool existsAfterRemove, FileStatus lastStatus, int removedIndexEntries) { - var path = CloneMergedTestRepo(); + var path = SandboxMergedTestRepo(); using (var repo = new Repository(path)) { int count = repo.Index.Count; @@ -92,7 +92,7 @@ public void CanResolveConflictsByRemovingFromTheIndex( [Fact] public void CanGetOriginalNamesOfRenameConflicts() { - var path = CloneMergeRenamesTestRepo(); + var path = Sandbox(MergeRenamesTestRepoWorkingDirPath); using (var repo = new Repository(path)) { var expected = RenameConflictData; @@ -115,7 +115,8 @@ public void CanGetOriginalNamesOfRenameConflicts() [Theory, PropertyData("ConflictData")] public void CanRetrieveSingleConflictByPath(string filepath, string ancestorId, string ourId, string theirId) { - using (var repo = new Repository(MergedTestRepoWorkingDirPath)) + var path = SandboxMergedTestRepo(); + using (var repo = new Repository(path)) { Conflict conflict = repo.Index.Conflicts[filepath]; Assert.NotNull(conflict); @@ -162,7 +163,8 @@ private string GetId(IndexEntry e) [Fact] public void CanRetrieveAllConflicts() { - using (var repo = new Repository(MergedTestRepoWorkingDirPath)) + var path = SandboxMergedTestRepo(); + using (var repo = new Repository(path)) { var expected = repo.Index.Conflicts.Select(c => new[] { GetPath(c), GetId(c.Ancestor), GetId(c.Ours), GetId(c.Theirs) }).ToArray(); Assert.Equal(expected, ConflictData); diff --git a/LibGit2Sharp.Tests/CurrentOperationFixture.cs b/LibGit2Sharp.Tests/CurrentOperationFixture.cs index 5b9200310..8944bbeb4 100644 --- a/LibGit2Sharp.Tests/CurrentOperationFixture.cs +++ b/LibGit2Sharp.Tests/CurrentOperationFixture.cs @@ -23,7 +23,8 @@ public void CurrentOperationIsNoneForNewRepo(bool isBare) [Fact] public void CurrentOperationInNoneForABareRepo() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Equal(CurrentOperation.None, repo.Info.CurrentOperation); } @@ -41,7 +42,7 @@ public void CurrentOperationInNoneForABareRepo() [InlineData("rebase-merge/whatever", CurrentOperation.RebaseMerge)] public void CurrentOperationHasExpectedPendingOperationValues(string stateFile, CurrentOperation expectedState) { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); Touch(Path.Combine(path, ".git"), stateFile); diff --git a/LibGit2Sharp.Tests/DiffBlobToBlobFixture.cs b/LibGit2Sharp.Tests/DiffBlobToBlobFixture.cs index c0711a468..00ef0ab2b 100644 --- a/LibGit2Sharp.Tests/DiffBlobToBlobFixture.cs +++ b/LibGit2Sharp.Tests/DiffBlobToBlobFixture.cs @@ -10,7 +10,8 @@ public class DiffBlobToBlobFixture : BaseFixture [Fact] public void ComparingABlobAgainstItselfReturnsNoDifference() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { var blob = repo.Lookup("7909961"); @@ -25,7 +26,8 @@ public void ComparingABlobAgainstItselfReturnsNoDifference() [Fact] public void CanCompareTwoVersionsOfABlobWithADiffOfTwoHunks() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { var oldblob = repo.Lookup("7909961"); var newblob = repo.Lookup("4e935b7"); @@ -72,7 +74,7 @@ Blob CreateBinaryBlob(IRepository repo) [Fact] public void CanCompareATextualBlobAgainstABinaryBlob() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Blob binBlob = CreateBinaryBlob(repo); @@ -91,7 +93,8 @@ public void CanCompareATextualBlobAgainstABinaryBlob() [Fact] public void CanCompareABlobAgainstANullBlob() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { var blob = repo.Lookup("7909961"); @@ -112,7 +115,8 @@ public void CanCompareABlobAgainstANullBlob() [Fact] public void ComparingTwoNullBlobsReturnsAnEmptyContentChanges() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { ContentChanges changes = repo.Diff.Compare((Blob)null, (Blob)null); diff --git a/LibGit2Sharp.Tests/DiffTreeToTargetFixture.cs b/LibGit2Sharp.Tests/DiffTreeToTargetFixture.cs index 79055475f..b5de35e57 100644 --- a/LibGit2Sharp.Tests/DiffTreeToTargetFixture.cs +++ b/LibGit2Sharp.Tests/DiffTreeToTargetFixture.cs @@ -66,7 +66,8 @@ public void CanCompareASimpleTreeAgainstTheWorkDir() [Fact] public void CanCompareAMoreComplexTreeAgainstTheWorkdir() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree tree = repo.Head.Tip.Tree; @@ -270,7 +271,8 @@ public void CanCompareASimpleTreeAgainstTheIndex() [Fact] public void CanCompareAMoreComplexTreeAgainstTheIndex() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree tree = repo.Head.Tip.Tree; @@ -297,7 +299,8 @@ public void CanCompareAMoreComplexTreeAgainstTheIndex() [Fact] public void CanCompareASubsetofTheTreeAgainstTheIndex() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree tree = repo.Head.Tip.Tree; @@ -321,7 +324,8 @@ private static void AssertCanCompareASubsetOfTheTreeAgainstTheIndex(TreeChanges [Fact] public void CanCompareASubsetofTheTreeAgainstTheIndexWithLaxExplicitPathsValidationAndANonExistentPath() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree tree = repo.Head.Tip.Tree; @@ -338,7 +342,8 @@ public void CanCompareASubsetofTheTreeAgainstTheIndexWithLaxExplicitPathsValidat [Fact] public void ComparingASubsetofTheTreeAgainstTheIndexWithStrictExplicitPathsValidationAndANonExistentPathThrows() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree tree = repo.Head.Tip.Tree; @@ -402,7 +407,8 @@ public void CanCopeWithEndOfFileNewlineChanges() [Fact] public void ComparingATreeInABareRepositoryAgainstTheWorkDirOrTheIndexThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws( () => repo.Diff.Compare(repo.Head.Tip.Tree, DiffTargets.WorkingDirectory)); diff --git a/LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs b/LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs index 2ba238f4f..99603b69e 100644 --- a/LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs +++ b/LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs @@ -15,7 +15,8 @@ public class DiffTreeToTreeFixture : BaseFixture [Fact] public void ComparingATreeAgainstItselfReturnsNoDifference() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree tree = repo.Head.Tip.Tree; @@ -31,7 +32,8 @@ public void ComparingATreeAgainstItselfReturnsNoDifference() [Fact] public void RetrievingANonExistentFileChangeReturnsNull() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree tree = repo.Head.Tip.Tree; @@ -49,7 +51,8 @@ public void RetrievingANonExistentFileChangeReturnsNull() [Fact] public void CanCompareACommitTreeAgainstItsParent() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree commitTree = repo.Head.Tip.Tree; Tree parentCommitTree = repo.Head.Tip.Parents.Single().Tree; @@ -89,7 +92,7 @@ static void CreateBinaryFile(string path) [Fact] public void CanDetectABinaryChange() { - using (var repo = new Repository(CloneStandardTestRepo())) + using (var repo = new Repository(SandboxStandardTestRepo())) { const string filename = "binfile.foo"; var filepath = Path.Combine(repo.Info.WorkingDirectory, filename); @@ -115,7 +118,7 @@ public void CanDetectABinaryChange() [Fact] public void CanDetectABinaryDeletion() { - using (var repo = new Repository(CloneStandardTestRepo())) + using (var repo = new Repository(SandboxStandardTestRepo())) { const string filename = "binfile.foo"; var filepath = Path.Combine(repo.Info.WorkingDirectory, filename); @@ -151,7 +154,8 @@ public void CanDetectABinaryDeletion() [Fact] public void CanCompareASubsetofTheTreeAgainstOneOfItsAncestor() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree tree = repo.Head.Tip.Tree; Tree ancestor = repo.Lookup("9fd738e").Tree; @@ -181,7 +185,8 @@ public void CanCompareASubsetofTheTreeAgainstOneOfItsAncestor() [Fact] public void CanCompareACommitTreeAgainstATreeWithNoCommonAncestor() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree commitTree = repo.Head.Tip.Tree; Tree commitTreeWithDifferentAncestor = repo.Branches["refs/remotes/origin/test"].Tip.Tree; @@ -206,7 +211,8 @@ public void CanCompareACommitTreeAgainstATreeWithNoCommonAncestor() [Fact] public void CanCompareATreeAgainstAnotherTreeWithLaxExplicitPathsValidationAndNonExistentPath() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree commitTree = repo.Head.Tip.Tree; Tree commitTreeWithDifferentAncestor = repo.Branches["refs/remotes/origin/test"].Tip.Tree; @@ -224,7 +230,8 @@ public void CanCompareATreeAgainstAnotherTreeWithLaxExplicitPathsValidationAndNo [Fact] public void ComparingATreeAgainstAnotherTreeWithStrictExplicitPathsValidationThrows() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree commitTree = repo.Head.Tip.Tree; Tree commitTreeWithDifferentAncestor = repo.Branches["refs/remotes/origin/test"].Tip.Tree; @@ -256,7 +263,8 @@ public void ComparingATreeAgainstAnotherTreeWithStrictExplicitPathsValidationThr [Fact] public void DetectsTheRenamingOfAModifiedFileByDefault() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree rootCommitTree = repo.Lookup("f8d44d7").Tree; Tree commitTreeWithRenamedFile = repo.Lookup("4be51d6").Tree; @@ -771,7 +779,8 @@ public void CanDetectTheExactRenamingExactCopyingOfNonModifiedAndModifiedFilesWh [InlineData(4, 193)] public void CanCompareTwoVersionsOfAFileWithATrailingNewlineDeletion(int contextLines, int expectedPatchLength) { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree rootCommitTree = repo.Lookup("f8d44d7").Tree; Tree commitTreeWithUpdatedFile = repo.Lookup("ec9e401").Tree; @@ -866,7 +875,8 @@ public void CanCompareTwoVersionsOfAFileWithADiffOfTwoHunks(int contextLines, in Similarity = SimilarityOptions.None, }; - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree rootCommitTree = repo.Lookup("f8d44d7").Tree; Tree mergedCommitTree = repo.Lookup("7252fe2").Tree; @@ -964,7 +974,8 @@ public void CanHandleTwoTreeEntryChangesWithTheSamePath() [Fact] public void CanCompareATreeAgainstANullTree() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Tree tree = repo.Branches["refs/remotes/origin/test"].Tip.Tree; @@ -987,7 +998,8 @@ public void CanCompareATreeAgainstANullTree() [Fact] public void ComparingTwoNullTreesReturnsAnEmptyTreeChanges() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { var changes = repo.Diff.Compare(default(Tree), default(Tree)); @@ -1000,7 +1012,7 @@ public void ComparingReliesOnProvidedConfigEntriesIfAny() { const string file = "1/branch_file.txt"; - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { TreeEntry entry = repo.Head[file]; @@ -1100,7 +1112,8 @@ public void RetrievingDiffChangesMustAlwaysBeCaseSensitive() [Fact] public void CallingCompareWithAnUnsupportedGenericParamThrows() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Diff.Compare(default(Tree), default(Tree))); Assert.Throws(() => repo.Diff.Compare()); diff --git a/LibGit2Sharp.Tests/DiffWorkdirToIndexFixture.cs b/LibGit2Sharp.Tests/DiffWorkdirToIndexFixture.cs index fd0a34b44..c16fd9882 100644 --- a/LibGit2Sharp.Tests/DiffWorkdirToIndexFixture.cs +++ b/LibGit2Sharp.Tests/DiffWorkdirToIndexFixture.cs @@ -30,7 +30,8 @@ public class DiffWorkdirToIndexFixture : BaseFixture [Fact] public void CanCompareTheWorkDirAgainstTheIndex() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { var changes = repo.Diff.Compare(); @@ -45,7 +46,8 @@ public void CanCompareTheWorkDirAgainstTheIndex() [InlineData("really-i-cant-exist.txt", FileStatus.Nonexistent)] public void CanCompareTheWorkDirAgainstTheIndexWithLaxUnmatchedExplicitPathsValidation(string relativePath, FileStatus currentStatus) { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath)); @@ -62,7 +64,8 @@ public void CanCompareTheWorkDirAgainstTheIndexWithLaxUnmatchedExplicitPathsVali [InlineData("really-i-cant-exist.txt", FileStatus.Nonexistent)] public void ComparingTheWorkDirAgainstTheIndexWithStrictUnmatchedExplicitPathsValidationAndANonExistentPathspecThrows(string relativePath, FileStatus currentStatus) { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath)); @@ -77,7 +80,8 @@ public void CallbackForUnmatchedExplicitPathsIsCalledWhenSet(string relativePath { var callback = new AssertUnmatchedPathspecsCallbackIsCalled(); - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath)); @@ -105,7 +109,7 @@ public void ComparingReliesOnProvidedConfigEntriesIfAny() { const string file = "1/branch_file.txt"; - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { TreeEntry entry = repo.Head[file]; @@ -171,7 +175,8 @@ private RepositoryOptions BuildFakeSystemConfigFilemodeOption( [Fact] public void CanCompareTheWorkDirAgainstTheIndexWithUntrackedFiles() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { var changes = repo.Diff.Compare(null, true); diff --git a/LibGit2Sharp.Tests/FilterBranchFixture.cs b/LibGit2Sharp.Tests/FilterBranchFixture.cs index bdfb137ee..dfe14329e 100644 --- a/LibGit2Sharp.Tests/FilterBranchFixture.cs +++ b/LibGit2Sharp.Tests/FilterBranchFixture.cs @@ -15,7 +15,7 @@ public class FilterBranchFixture : BaseFixture public FilterBranchFixture() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); repo = new Repository(path); } diff --git a/LibGit2Sharp.Tests/IgnoreFixture.cs b/LibGit2Sharp.Tests/IgnoreFixture.cs index 523a08c8b..790336512 100644 --- a/LibGit2Sharp.Tests/IgnoreFixture.cs +++ b/LibGit2Sharp.Tests/IgnoreFixture.cs @@ -11,7 +11,7 @@ public class IgnoreFixture : BaseFixture [Fact] public void TemporaryRulesShouldApplyUntilCleared() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Touch(repo.Info.WorkingDirectory, "Foo.cs", "Bar"); @@ -31,7 +31,7 @@ public void TemporaryRulesShouldApplyUntilCleared() [Fact] public void IsPathIgnoredShouldVerifyWhetherPathIsIgnored() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Touch(repo.Info.WorkingDirectory, "Foo.cs", "Bar"); @@ -51,7 +51,8 @@ public void IsPathIgnoredShouldVerifyWhetherPathIsIgnored() [Fact] public void CallingIsPathIgnoredWithBadParamsThrows() { - using (var repo = new Repository(StandardTestRepoWorkingDirPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Ignore.IsPathIgnored(string.Empty)); Assert.Throws(() => repo.Ignore.IsPathIgnored(null)); @@ -61,7 +62,8 @@ public void CallingIsPathIgnoredWithBadParamsThrows() [Fact] public void AddingATemporaryRuleWithBadParamsThrows() { - using (var repo = new Repository(StandardTestRepoWorkingDirPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Ignore.AddTemporaryRules(null)); } @@ -70,7 +72,7 @@ public void AddingATemporaryRuleWithBadParamsThrows() [Fact] public void CanCheckIfAPathIsIgnoredUsingThePreferedPlatformDirectorySeparatorChar() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Touch(repo.Info.WorkingDirectory, ".gitignore", "/NewFolder\n/NewFolder/NewFolder"); diff --git a/LibGit2Sharp.Tests/IndexFixture.cs b/LibGit2Sharp.Tests/IndexFixture.cs index a1ec882a3..947622363 100644 --- a/LibGit2Sharp.Tests/IndexFixture.cs +++ b/LibGit2Sharp.Tests/IndexFixture.cs @@ -28,7 +28,8 @@ public class IndexFixture : BaseFixture [Fact] public void CanCountEntriesInIndex() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Equal(expectedEntries.Count(), repo.Index.Count); } @@ -37,7 +38,8 @@ public void CanCountEntriesInIndex() [Fact] public void CanEnumerateIndex() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Equal(expectedEntries, repo.Index.Select(e => e.Path).OrderBy(p => p, StringComparer.Ordinal).ToArray()); @@ -47,7 +49,8 @@ public void CanEnumerateIndex() [Fact] public void CanFetchAnIndexEntryByItsName() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { IndexEntry entry = repo.Index["README"]; Assert.Equal("README", entry.Path); @@ -65,7 +68,8 @@ public void CanFetchAnIndexEntryByItsName() [Fact] public void FetchingAnUnknownIndexEntryReturnsNull() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { IndexEntry entry = repo.Index["I-do-not-exist.txt"]; Assert.Null(entry); @@ -75,7 +79,8 @@ public void FetchingAnUnknownIndexEntryReturnsNull() [Fact] public void ReadIndexWithBadParamsFails() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Throws(() => { IndexEntry entry = repo.Index[null]; }); Assert.Throws(() => { IndexEntry entry = repo.Index[string.Empty]; }); @@ -139,7 +144,7 @@ public void CanRenameAFile() [InlineData("modified_unstaged_file.txt", FileStatus.Modified, "deleted_unstaged_file.txt", FileStatus.Missing, FileStatus.Removed, FileStatus.Staged)] public void CanMoveAnExistingFileOverANonExistingFile(string sourcePath, FileStatus sourceStatus, string destPath, FileStatus destStatus, FileStatus sourcePostStatus, FileStatus destPostStatus) { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Assert.Equal(sourceStatus, repo.RetrieveStatus(sourcePath)); @@ -178,9 +183,10 @@ public void MovingAFileNotInTheWorkingDirectoryThrows(string sourcePath, FileSta InvalidMoveUseCases(sourcePath, sourceStatus, destPaths); } - private static void InvalidMoveUseCases(string sourcePath, FileStatus sourceStatus, IEnumerable destPaths) + private void InvalidMoveUseCases(string sourcePath, FileStatus sourceStatus, IEnumerable destPaths) { - using (var repo = new Repository(StandardTestRepoPath)) + var repoPath = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(repoPath)) { Assert.Equal(sourceStatus, repo.RetrieveStatus(sourcePath)); @@ -224,7 +230,8 @@ public void PathsOfIndexEntriesAreExpressedInNativeFormat() [Fact] public void CanReadIndexEntryAttributes() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Equal(Mode.NonExecutableFile, repo.Index["README"].Mode); Assert.Equal(Mode.ExecutableFile, repo.Index["1/branch_file.txt"].Mode); @@ -282,7 +289,7 @@ public void CanCopeWithExternalChangesToTheIndex() [Fact] public void CanResetFullyMergedIndexFromTree() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); const string testFile = "new_tracked_file.txt"; @@ -313,7 +320,7 @@ public void CanResetFullyMergedIndexFromTree() [Fact] public void CanResetIndexWithUnmergedEntriesFromTree() { - string path = CloneMergedTestRepo(); + string path = SandboxMergedTestRepo(); const string testFile = "one.txt"; @@ -344,7 +351,7 @@ public void CanResetIndexWithUnmergedEntriesFromTree() [Fact] public void CanClearTheIndex() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); const string testFile = "1.txt"; // It is sufficient to check just one of the stage area changes, such as the modified file, diff --git a/LibGit2Sharp.Tests/MergeFixture.cs b/LibGit2Sharp.Tests/MergeFixture.cs index 428a6f677..13178e245 100644 --- a/LibGit2Sharp.Tests/MergeFixture.cs +++ b/LibGit2Sharp.Tests/MergeFixture.cs @@ -24,7 +24,8 @@ public void ANewRepoIsFullyMerged() [Fact] public void AFullyMergedRepoOnlyContainsStagedIndexEntries() { - using (var repo = new Repository(StandardTestRepoWorkingDirPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { Assert.Equal(true, repo.Index.IsFullyMerged); @@ -38,7 +39,8 @@ public void AFullyMergedRepoOnlyContainsStagedIndexEntries() [Fact] public void SoftResetARepoWithUnmergedEntriesThrows() { - using (var repo = new Repository(MergedTestRepoWorkingDirPath)) + var path = SandboxMergedTestRepo(); + using (var repo = new Repository(path)) { Assert.Equal(false, repo.Index.IsFullyMerged); @@ -52,7 +54,8 @@ public void SoftResetARepoWithUnmergedEntriesThrows() [Fact] public void CommitAgainARepoWithUnmergedEntriesThrows() { - using (var repo = new Repository(MergedTestRepoWorkingDirPath)) + var path = SandboxMergedTestRepo(); + using (var repo = new Repository(path)) { Assert.Equal(false, repo.Index.IsFullyMerged); @@ -65,7 +68,7 @@ public void CommitAgainARepoWithUnmergedEntriesThrows() [Fact] public void CanRetrieveTheBranchBeingMerged() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { const string firstBranch = "9fd738e8f7967c078dceed8190330fc8648ee56a"; @@ -86,7 +89,7 @@ public void CanMergeRepoNonFastForward(bool shouldMergeOccurInDetachedHeadState) const string secondBranchFileName = "second branch file.txt"; const string sharedBranchFileName = "first+second branch file.txt"; - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { @@ -136,7 +139,7 @@ public void IsUpToDateMerge() { const string sharedBranchFileName = "first+second branch file.txt"; - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { var firstBranch = repo.CreateBranch("FirstBranch"); @@ -163,7 +166,7 @@ public void CanFastForwardRepos(bool shouldMergeOccurInDetachedHeadState) const string firstBranchFileName = "first branch file.txt"; const string sharedBranchFileName = "first+second branch file.txt"; - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { // Reset the index and the working tree. @@ -220,7 +223,7 @@ public void ConflictingMergeRepos() const string secondBranchFileName = "second branch file.txt"; const string sharedBranchFileName = "first+second branch file.txt"; - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { var firstBranch = repo.CreateBranch("FirstBranch"); @@ -260,7 +263,7 @@ public void ConflictingMergeReposBinary() const string secondBranchFileName = "second branch file.bin"; const string sharedBranchFileName = "first+second branch file.bin"; - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { var firstBranch = repo.CreateBranch("FirstBranch"); @@ -300,7 +303,7 @@ public void ConflictingMergeReposBinary() [InlineData(false, FastForwardStrategy.FastForwardOnly, fastForwardBranchInitialId, MergeStatus.FastForward)] public void CanFastForwardCommit(bool fromDetachedHead, FastForwardStrategy fastForwardStrategy, string expectedCommitId, MergeStatus expectedMergeStatus) { - string path = CloneMergeTestRepo(); + string path = SandboxMergeTestRepo(); using (var repo = new Repository(path)) { if(fromDetachedHead) @@ -326,7 +329,7 @@ public void CanFastForwardCommit(bool fromDetachedHead, FastForwardStrategy fast [InlineData(false, FastForwardStrategy.NoFastFoward, MergeStatus.NonFastForward)] public void CanNonFastForwardMergeCommit(bool fromDetachedHead, FastForwardStrategy fastForwardStrategy, MergeStatus expectedMergeStatus) { - string path = CloneMergeTestRepo(); + string path = SandboxMergeTestRepo(); using (var repo = new Repository(path)) { if (fromDetachedHead) @@ -347,7 +350,7 @@ public void CanNonFastForwardMergeCommit(bool fromDetachedHead, FastForwardStrat [Fact] public void MergeReportsCheckoutProgress() { - string repoPath = CloneMergeTestRepo(); + string repoPath = SandboxMergeTestRepo(); using (var repo = new Repository(repoPath)) { Commit commitToMerge = repo.Branches["normal_merge"].Tip; @@ -368,7 +371,7 @@ public void MergeReportsCheckoutProgress() [Fact] public void MergeReportsCheckoutNotifications() { - string repoPath = CloneMergeTestRepo(); + string repoPath = SandboxMergeTestRepo(); using (var repo = new Repository(repoPath)) { Commit commitToMerge = repo.Branches["normal_merge"].Tip; @@ -392,7 +395,7 @@ public void MergeReportsCheckoutNotifications() [Fact] public void FastForwardMergeReportsCheckoutProgress() { - string repoPath = CloneMergeTestRepo(); + string repoPath = SandboxMergeTestRepo(); using (var repo = new Repository(repoPath)) { Commit commitToMerge = repo.Branches["fast_forward"].Tip; @@ -413,7 +416,7 @@ public void FastForwardMergeReportsCheckoutProgress() [Fact] public void FastForwardMergeReportsCheckoutNotifications() { - string repoPath = CloneMergeTestRepo(); + string repoPath = SandboxMergeTestRepo(); using (var repo = new Repository(repoPath)) { Commit commitToMerge = repo.Branches["fast_forward"].Tip; @@ -446,7 +449,7 @@ public void MergeCanDetectRenames() // but the merge will fail with conflicts if this // change is not detected as a rename. - string repoPath = CloneMergeTestRepo(); + string repoPath = SandboxMergeTestRepo(); using (var repo = new Repository(repoPath)) { Branch currentBranch = repo.Checkout("rename_source"); @@ -463,7 +466,7 @@ public void MergeCanDetectRenames() [Fact] public void FastForwardNonFastForwardableMergeThrows() { - string path = CloneMergeTestRepo(); + string path = SandboxMergeTestRepo(); using (var repo = new Repository(path)) { Commit commitToMerge = repo.Branches["normal_merge"].Tip; @@ -474,7 +477,7 @@ public void FastForwardNonFastForwardableMergeThrows() [Fact] public void CanForceFastForwardMergeThroughConfig() { - string path = CloneMergeTestRepo(); + string path = SandboxMergeTestRepo(); using (var repo = new Repository(path)) { repo.Config.Set("merge.ff", "only"); @@ -487,7 +490,7 @@ public void CanForceFastForwardMergeThroughConfig() [Fact] public void CanMergeAndNotCommit() { - string path = CloneMergeTestRepo(); + string path = SandboxMergeTestRepo(); using (var repo = new Repository(path)) { Commit commitToMerge = repo.Branches["normal_merge"].Tip; @@ -508,7 +511,7 @@ public void CanMergeAndNotCommit() [Fact] public void CanForceNonFastForwardMerge() { - string path = CloneMergeTestRepo(); + string path = SandboxMergeTestRepo(); using (var repo = new Repository(path)) { Commit commitToMerge = repo.Branches["fast_forward"].Tip; @@ -524,7 +527,7 @@ public void CanForceNonFastForwardMerge() [Fact] public void CanForceNonFastForwardMergeThroughConfig() { - string path = CloneMergeTestRepo(); + string path = SandboxMergeTestRepo(); using (var repo = new Repository(path)) { repo.Config.Set("merge.ff", "false"); @@ -542,7 +545,7 @@ public void CanForceNonFastForwardMergeThroughConfig() [Fact] public void VerifyUpToDateMerge() { - string path = CloneMergeTestRepo(); + string path = SandboxMergeTestRepo(); using (var repo = new Repository(path)) { Commit commitToMerge = repo.Branches["master"].Tip; @@ -562,7 +565,7 @@ public void VerifyUpToDateMerge() [InlineData("fast_forward", FastForwardStrategy.Default, MergeStatus.FastForward)] public void CanMergeCommittish(string committish, FastForwardStrategy strategy, MergeStatus expectedMergeStatus) { - string path = CloneMergeTestRepo(); + string path = SandboxMergeTestRepo(); using (var repo = new Repository(path)) { MergeResult result = repo.Merge(committish, Constants.Signature, new MergeOptions() { FastForwardStrategy = strategy }); @@ -585,7 +588,7 @@ public void MergeWithWorkDirConflictsThrows(bool shouldStage, FastForwardStrateg // due to merge conflicts. string committishToMerge = "fast_forward"; - using (var repo = new Repository(CloneMergeTestRepo())) + using (var repo = new Repository(SandboxMergeTestRepo())) { Touch(repo.Info.WorkingDirectory, "b.txt", "this is an alternate change"); @@ -606,7 +609,7 @@ public void CanSpecifyConflictFileStrategy(CheckoutFileConflictStrategy conflict const string conflictFile = "a.txt"; const string conflictBranchName = "conflicts"; - string path = CloneMergeTestRepo(); + string path = SandboxMergeTestRepo(); using (var repo = new Repository(path)) { Branch branch = repo.Branches[conflictBranchName]; @@ -657,7 +660,7 @@ public void MergeCanSpecifyMergeFileFavorOption(MergeFileFavor fileFavorFlag) const string conflictFile = "a.txt"; const string conflictBranchName = "conflicts"; - string path = CloneMergeTestRepo(); + string path = SandboxMergeTestRepo(); using (var repo = InitIsolatedRepository(path)) { Branch branch = repo.Branches[conflictBranchName]; @@ -709,7 +712,7 @@ public void MergeCanSpecifyMergeFileFavorOption(MergeFileFavor fileFavorFlag) [InlineData("fast_forward", FastForwardStrategy.Default, MergeStatus.FastForward)] public void CanMergeBranch(string branchName, FastForwardStrategy strategy, MergeStatus expectedMergeStatus) { - string path = CloneMergeTestRepo(); + string path = SandboxMergeTestRepo(); using (var repo = new Repository(path)) { Branch branch = repo. Branches[branchName]; @@ -723,7 +726,7 @@ public void CanMergeBranch(string branchName, FastForwardStrategy strategy, Merg [Fact] public void CanMergeIntoOrphanedBranch() { - string path = CloneMergeTestRepo(); + string path = SandboxMergeTestRepo(); using (var repo = new Repository(path)) { repo.Refs.Add("HEAD", "refs/heads/orphan", true); diff --git a/LibGit2Sharp.Tests/MockingFixture.cs b/LibGit2Sharp.Tests/MockingFixture.cs index 13376fae1..6b99a6bb8 100644 --- a/LibGit2Sharp.Tests/MockingFixture.cs +++ b/LibGit2Sharp.Tests/MockingFixture.cs @@ -18,7 +18,8 @@ public class MockingFixture : BaseFixture [Fact] public void CanCountCommitsWithConcreteRepository() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var commitCounter = new CommitCounter(repo); Assert.Equal(7, commitCounter.NumberOfCommits); diff --git a/LibGit2Sharp.Tests/NoteFixture.cs b/LibGit2Sharp.Tests/NoteFixture.cs index ad2e66040..7da99db07 100644 --- a/LibGit2Sharp.Tests/NoteFixture.cs +++ b/LibGit2Sharp.Tests/NoteFixture.cs @@ -15,7 +15,8 @@ public class NoteFixture : BaseFixture [Fact] public void RetrievingNotesFromANonExistingGitObjectYieldsNoResult() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var notes = repo.Notes[ObjectId.Zero]; @@ -26,7 +27,8 @@ public void RetrievingNotesFromANonExistingGitObjectYieldsNoResult() [Fact] public void RetrievingNotesFromAGitObjectWhichHasNoNoteYieldsNoResult() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var notes = repo.Notes[new ObjectId("4c062a6361ae6959e06292c1fa5e2822d9c96345")]; @@ -56,7 +58,8 @@ public void CanRetrieveNotesFromAGitObject() { var expectedMessages = new [] { "Just Note, don't you understand?\n", "Nope\n", "Not Nope, Note!\n" }; - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var notes = repo.Notes[new ObjectId("4a202b346bb0fb0db7eff3cffeb3c70babbd2045")]; @@ -68,7 +71,8 @@ public void CanRetrieveNotesFromAGitObject() [Fact] public void CanRetrieveASpecificNoteFromAKnownNamespace() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var singleNote = repo.Notes["answer", new ObjectId("4a202b346bb0fb0db7eff3cffeb3c70babbd2045")]; Assert.Equal("Nope\n", singleNote.Message); @@ -80,7 +84,8 @@ public void CanGetListOfNotesNamespaces() { var expectedNamespaces = new[] { "answer", "answer2", "commits", }; - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Equal(expectedNamespaces, repo.Notes.Namespaces.OrderBy(n => n, StringComparer.Ordinal).ToArray()); @@ -110,7 +115,7 @@ public void CanAccessNotesFromACommit() { var expectedNamespaces = new[] { "Just Note, don't you understand?\n", "Nope\n", "Not Nope, Note!\n" }; - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { var commit = repo.Lookup("4a202b346bb0fb0db7eff3cffeb3c70babbd2045"); @@ -127,7 +132,7 @@ public void CanAccessNotesFromACommit() [Fact] public void CanAddANoteOnAGitObject() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { var commit = repo.Lookup("9fd738e8f7967c078dceed8190330fc8648ee56a"); @@ -144,7 +149,7 @@ public void CanAddANoteOnAGitObject() [Fact] public void CreatingANoteWhichAlreadyExistsOverwritesThePreviousNote() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { var commit = repo.Lookup("5b5b025afb0b4c913b4c338a42934a3863bf3644"); @@ -165,7 +170,7 @@ public void CanAddANoteWithSignatureFromConfig() { string configPath = CreateConfigurationWithDummyUser(Constants.Signature); var options = new RepositoryOptions { GlobalConfigurationLocation = configPath }; - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path, options)) { @@ -185,7 +190,7 @@ public void CanAddANoteWithSignatureFromConfig() [Fact] public void CanCompareTwoUniqueNotes() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { var commit = repo.Lookup("9fd738e8f7967c078dceed8190330fc8648ee56a"); @@ -220,7 +225,7 @@ public void CanCompareTwoUniqueNotes() [Fact] public void CanRemoveANoteFromAGitObject() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { var commit = repo.Lookup("8496071c1b46c854b31185ea97743be6a8774479"); @@ -248,7 +253,7 @@ public void CanRemoveANoteFromAGitObject() [Fact] public void RemovingANonExistingNoteDoesntThrow() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { var commit = repo.Lookup("5b5b025afb0b4c913b4c338a42934a3863bf3644"); @@ -262,7 +267,7 @@ public void CanRemoveANoteWithSignatureFromConfig() { string configPath = CreateConfigurationWithDummyUser(Constants.Signature); RepositoryOptions options = new RepositoryOptions() { GlobalConfigurationLocation = configPath }; - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path, options)) { @@ -288,7 +293,8 @@ public void CanRetrieveTheListOfNotesForAGivenNamespace() new { Blob = "1a550e416326cdb4a8e127a04dd69d7a01b11cf4", Target = "4a202b346bb0fb0db7eff3cffeb3c70babbd2045" }, }; - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Equal(expectedNotes, SortedNotes(repo.Notes["commits"], n => new { Blob = n.BlobId.Sha, Target = n.TargetObjectId.Sha })); diff --git a/LibGit2Sharp.Tests/ObjectDatabaseFixture.cs b/LibGit2Sharp.Tests/ObjectDatabaseFixture.cs index f26ba7105..1ec121e93 100644 --- a/LibGit2Sharp.Tests/ObjectDatabaseFixture.cs +++ b/LibGit2Sharp.Tests/ObjectDatabaseFixture.cs @@ -17,7 +17,8 @@ public class ObjectDatabaseFixture : BaseFixture [InlineData("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef", false)] public void CanTellIfObjectsExists(string sha, bool shouldExists) { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var oid = new ObjectId(sha); @@ -202,7 +203,7 @@ private static void CreateAttributesFiles(string where, string filename) [InlineData("1")] public void CanCreateATreeByAlteringAnExistingOne(string targetPath) { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { var blob = repo.Lookup(new ObjectId("a8233120f6ad708f843d861ce2b7228ec4e3dec6")); @@ -218,7 +219,7 @@ public void CanCreateATreeByAlteringAnExistingOne(string targetPath) [Fact] public void CanCreateATreeByRemovingEntriesFromExistingOne() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { TreeDefinition td = TreeDefinition.From(repo.Head.Tip.Tree) @@ -239,7 +240,7 @@ public void CanCreateATreeByRemovingEntriesFromExistingOne() [Fact] public void RemovingANonExistingEntryFromATreeDefinitionHasNoSideEffect() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Tree head = repo.Head.Tip.Tree; @@ -275,7 +276,7 @@ public void CanCreateAnEmptyTree() [Fact] public void CanReplaceAnExistingTreeWithAnotherPersitedTree() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { TreeDefinition td = TreeDefinition.From(repo.Head.Tip.Tree); @@ -296,7 +297,7 @@ public void CanReplaceAnExistingTreeWithAnotherPersitedTree() [Fact] public void CanCreateATreeContainingABlobFromAFileInTheWorkingDirectory() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Assert.Equal(FileStatus.Nonexistent, repo.RetrieveStatus("hello.txt")); @@ -328,7 +329,7 @@ public void CanCreateATreeContainingABlobFromAFileInTheWorkingDirectory() [Fact] public void CanCreateATreeContainingAGitLinkFromAnUntrackedSubmoduleInTheWorkingDirectory() { - string path = CloneSubmoduleTestRepo(); + string path = SandboxSubmoduleTestRepo(); using (var repo = new Repository(path)) { const string submodulePath = "sm_added_and_uncommited"; @@ -370,7 +371,8 @@ public void CanCreateATreeContainingAGitLinkFromAnUntrackedSubmoduleInTheWorking [Fact] public void CannotCreateATreeContainingABlobFromARelativePathAgainstABareRepository() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var td = new TreeDefinition() .Add("1/new file", "hello.txt", Mode.NonExecutableFile); @@ -382,7 +384,8 @@ public void CannotCreateATreeContainingABlobFromARelativePathAgainstABareReposit [Fact] public void CreatingATreeFromIndexWithUnmergedEntriesThrows() { - using (var repo = new Repository(MergedTestRepoWorkingDirPath)) + var path = SandboxMergedTestRepo(); + using (var repo = new Repository(path)) { Assert.False(repo.Index.IsFullyMerged); @@ -394,7 +397,7 @@ public void CreatingATreeFromIndexWithUnmergedEntriesThrows() [Fact] public void CanCreateATreeFromIndex() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { @@ -416,7 +419,7 @@ public void CanCreateATreeFromIndex() [Fact] public void CanCreateACommit() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Branch head = repo.Head; @@ -456,7 +459,7 @@ public void CanCreateABinaryBlobFromAStream() [Fact] public void CanCreateATagAnnotationPointingToAGitObject() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { var blob = repo.Head.Tip["README"].Target as Blob; @@ -482,7 +485,8 @@ public void CanCreateATagAnnotationPointingToAGitObject() [Fact] public void CanEnumerateTheGitObjectsFromBareRepository() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { int count = 0; @@ -504,7 +508,8 @@ public void CanEnumerateTheGitObjectsFromBareRepository() [InlineData("\0\0\0")] public void CreatingACommitWithMessageContainingZeroByteThrows(string message) { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.ObjectDatabase.CreateCommit( Constants.Signature, Constants.Signature, message, repo.Head.Tip.Tree, Enumerable.Empty(), false)); @@ -519,7 +524,8 @@ public void CreatingACommitWithMessageContainingZeroByteThrows(string message) [InlineData("\0\0\0")] public void CreatingATagAnnotationWithNameOrMessageContainingZeroByteThrows(string input) { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.ObjectDatabase.CreateTagAnnotation( input, repo.Head.Tip, Constants.Signature, "message")); @@ -531,7 +537,8 @@ public void CreatingATagAnnotationWithNameOrMessageContainingZeroByteThrows(stri [Fact] public void CreatingATagAnnotationWithBadParametersThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.ObjectDatabase.CreateTagAnnotation( null, repo.Head.Tip, Constants.Signature, "message")); @@ -549,7 +556,7 @@ public void CreatingATagAnnotationWithBadParametersThrows() [Fact] public void CanCreateATagAnnotationWithAnEmptyMessage() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { var tagAnnotation = repo.ObjectDatabase.CreateTagAnnotation( @@ -566,7 +573,8 @@ public void CanCalculateHistoryDivergence( string sinceSha, string untilSha, string expectedAncestorSha, int? expectedAheadBy, int? expectedBehindBy) { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var since = repo.Lookup(sinceSha); var until = repo.Lookup(untilSha); @@ -585,7 +593,8 @@ public void CanCalculateHistoryDivergenceWhenNoAncestorIsShared( string sinceSha, string untilSha, int? expectedAheadBy, int? expectedBehindBy) { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var since = repo.Lookup(sinceSha); var until = repo.Lookup(untilSha); @@ -601,7 +610,8 @@ public void CanCalculateHistoryDivergenceWhenNoAncestorIsShared( [Fact] public void CalculatingHistoryDivergenceWithBadParamsThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws( () => repo.ObjectDatabase.CalculateHistoryDivergence(repo.Head.Tip, null)); @@ -621,7 +631,7 @@ public void CanShortenObjectIdentifier() * dea509d097ce692e167dfc6a48a7a280cc5e877e */ - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { repo.Config.Set("core.abbrev", 4); diff --git a/LibGit2Sharp.Tests/OdbBackendFixture.cs b/LibGit2Sharp.Tests/OdbBackendFixture.cs index 161dcb938..2ca40a4cb 100644 --- a/LibGit2Sharp.Tests/OdbBackendFixture.cs +++ b/LibGit2Sharp.Tests/OdbBackendFixture.cs @@ -188,7 +188,7 @@ public void CanShortenObjectIdentifier() * dea509d097ce692e167dfc6a48a7a280cc5e877e */ - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { repo.ObjectDatabase.AddBackend(new MockOdbBackend(), 5); diff --git a/LibGit2Sharp.Tests/PatchStatsFixture.cs b/LibGit2Sharp.Tests/PatchStatsFixture.cs index 8b5ce40ee..41d3fdb23 100644 --- a/LibGit2Sharp.Tests/PatchStatsFixture.cs +++ b/LibGit2Sharp.Tests/PatchStatsFixture.cs @@ -8,7 +8,8 @@ public class PatchStatsFixture : BaseFixture [Fact] public void CanExtractStatisticsFromDiff() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { var oldTree = repo.Lookup("origin/packed-test").Tree; var newTree = repo.Lookup("HEAD").Tree; diff --git a/LibGit2Sharp.Tests/PushFixture.cs b/LibGit2Sharp.Tests/PushFixture.cs index d6b906ba6..f0e950465 100644 --- a/LibGit2Sharp.Tests/PushFixture.cs +++ b/LibGit2Sharp.Tests/PushFixture.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.Linq; using LibGit2Sharp.Tests.TestHelpers; using Xunit; @@ -17,7 +18,7 @@ private void AssertPush(Action push) { var scd = BuildSelfCleaningDirectory(); - string originalRepoPath = CloneBareTestRepo(); + string originalRepoPath = SandboxBareTestRepo(); string clonedRepoPath = Repository.Clone(originalRepoPath, scd.DirectoryPath); using (var originalRepo = new Repository(originalRepoPath)) @@ -159,7 +160,7 @@ private void UpdateTheRemoteRepositoryWithANewCommit(string remoteRepoPath) private Commit AddCommitToRepo(IRepository repository) { - string random = Guid.NewGuid().ToString(); + string random = Path.GetRandomFileName(); string filename = random + ".txt"; Touch(repository.Info.WorkingDirectory, filename, random); diff --git a/LibGit2Sharp.Tests/RefSpecFixture.cs b/LibGit2Sharp.Tests/RefSpecFixture.cs index 6e6cbd60f..1473ac704 100644 --- a/LibGit2Sharp.Tests/RefSpecFixture.cs +++ b/LibGit2Sharp.Tests/RefSpecFixture.cs @@ -11,7 +11,7 @@ public class RefSpecFixture : BaseFixture [Fact] public void CanCountRefSpecs() { - var path = CloneStandardTestRepo(); + var path = SandboxStandardTestRepo(); using (var repo = InitIsolatedRepository(path)) { var remote = repo.Network.Remotes["origin"]; @@ -22,7 +22,7 @@ public void CanCountRefSpecs() [Fact] public void CanIterateOverRefSpecs() { - var path = CloneStandardTestRepo(); + var path = SandboxStandardTestRepo(); using (var repo = InitIsolatedRepository(path)) { var remote = repo.Network.Remotes["origin"]; @@ -39,7 +39,7 @@ public void CanIterateOverRefSpecs() [Fact] public void FetchAndPushRefSpecsComposeRefSpecs() { - var path = CloneStandardTestRepo(); + var path = SandboxStandardTestRepo(); using (var repo = InitIsolatedRepository(path)) { var remote = repo.Network.Remotes["origin"]; @@ -53,7 +53,7 @@ public void FetchAndPushRefSpecsComposeRefSpecs() [Fact] public void CanReadRefSpecDetails() { - var path = CloneStandardTestRepo(); + var path = SandboxStandardTestRepo(); using (var repo = InitIsolatedRepository(path)) { var remote = repo.Network.Remotes["origin"]; @@ -73,7 +73,7 @@ public void CanReadRefSpecDetails() [InlineData(new string[0], new string[] { "refs/ghi:refs/jkl/mno" })] public void CanReplaceRefSpecs(string[] newFetchRefSpecs, string[] newPushRefSpecs) { - var path = CloneStandardTestRepo(); + var path = SandboxStandardTestRepo(); using (var repo = InitIsolatedRepository(path)) { var remote = repo.Network.Remotes["origin"]; @@ -103,7 +103,7 @@ public void RemoteUpdaterSavesRefSpecsPermanently() { var fetchRefSpecs = new string[] { "refs/their/heads/*:refs/my/heads/*", "+refs/their/tag:refs/my/tag" }; - var path = CloneStandardTestRepo(); + var path = SandboxStandardTestRepo(); using (var repo = InitIsolatedRepository(path)) { var remote = repo.Network.Remotes["origin"]; @@ -126,7 +126,7 @@ public void CanAddAndRemoveRefSpecs() { string newRefSpec = "+refs/heads/test:refs/heads/other-test"; - var path = CloneStandardTestRepo(); + var path = SandboxStandardTestRepo(); using (var repo = InitIsolatedRepository(path)) { var remote = repo.Network.Remotes["origin"]; @@ -150,7 +150,7 @@ public void CanAddAndRemoveRefSpecs() [Fact] public void CanClearRefSpecs() { - var path = CloneStandardTestRepo(); + var path = SandboxStandardTestRepo(); using (var repo = InitIsolatedRepository(path)) { var remote = repo.Network.Remotes["origin"]; @@ -178,7 +178,7 @@ public void CanClearRefSpecs() [InlineData("refs/ whitespace:refs/test")] public void SettingInvalidRefSpecsThrows(string refSpec) { - var path = CloneStandardTestRepo(); + var path = SandboxStandardTestRepo(); using (var repo = InitIsolatedRepository(path)) { var remote = repo.Network.Remotes["origin"]; diff --git a/LibGit2Sharp.Tests/ReferenceFixture.cs b/LibGit2Sharp.Tests/ReferenceFixture.cs index c3c71a836..3af887ad0 100644 --- a/LibGit2Sharp.Tests/ReferenceFixture.cs +++ b/LibGit2Sharp.Tests/ReferenceFixture.cs @@ -21,7 +21,7 @@ public void CanAddADirectReference() { const string name = "refs/heads/unit_test"; - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { EnableRefLog(repo); @@ -46,7 +46,7 @@ public void CanAddADirectReferenceFromRevParseSpec() const string name = "refs/heads/extendedShaSyntaxRulz"; const string logMessage = "Create new ref"; - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { EnableRefLog(repo); @@ -70,7 +70,7 @@ public void CreatingADirectReferenceWithARevparseSpecPointingAtAnUnknownObjectFa { const string name = "refs/heads/extendedShaSyntaxRulz"; - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Assert.Throws(() => repo.Refs.Add(name, "master^42")); @@ -83,7 +83,7 @@ public void CanAddASymbolicReferenceFromTheTargetName() const string name = "refs/heads/unit_test"; const string target = "refs/heads/master"; - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { var newRef = (SymbolicReference)repo.Refs.Add(name, target); @@ -99,7 +99,7 @@ public void CanAddASymbolicReferenceFromTheTargetReference() const string target = "refs/heads/master"; const string logMessage = "unit_test reference init"; - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { EnableRefLog(repo); @@ -126,7 +126,7 @@ private static void AssertSymbolicRef(SymbolicReference newRef, IRepository repo [Fact] public void BlindlyCreatingADirectReferenceOverAnExistingOneThrows() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Assert.Throws(() => repo.Refs.Add("refs/heads/master", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644")); @@ -136,7 +136,7 @@ public void BlindlyCreatingADirectReferenceOverAnExistingOneThrows() [Fact] public void BlindlyCreatingASymbolicReferenceOverAnExistingOneThrows() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Assert.Throws(() => repo.Refs.Add("HEAD", "refs/heads/br2")); @@ -150,7 +150,7 @@ public void CanAddAndOverwriteADirectReference() const string target = "4c062a6361ae6959e06292c1fa5e2822d9c96345"; const string logMessage = "Create new ref"; - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { EnableRefLog(repo); @@ -177,7 +177,7 @@ public void CanAddAndOverwriteASymbolicReference() const string target = "refs/heads/br2"; const string logMessage = "Create new ref"; - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { EnableRefLog(repo); @@ -200,7 +200,8 @@ public void CanAddAndOverwriteASymbolicReference() [Fact] public void AddWithEmptyStringForTargetThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Refs.Add("refs/heads/newref", string.Empty)); } @@ -209,7 +210,8 @@ public void AddWithEmptyStringForTargetThrows() [Fact] public void AddWithEmptyStringThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Refs.Add(string.Empty, "refs/heads/master")); } @@ -218,7 +220,8 @@ public void AddWithEmptyStringThrows() [Fact] public void AddWithNullForTargetThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Refs.Add("refs/heads/newref", (string)null)); Assert.Throws(() => repo.Refs.Add("refs/heads/newref", (ObjectId)null)); @@ -228,7 +231,8 @@ public void AddWithNullForTargetThrows() [Fact] public void AddWithNullStringThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Refs.Add(null, "refs/heads/master")); } @@ -237,7 +241,7 @@ public void AddWithNullStringThrows() [Fact] public void CanRemoveAReference() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { repo.Refs.Remove("refs/heads/packed"); @@ -247,7 +251,7 @@ public void CanRemoveAReference() [Fact] public void CanRemoveANonExistingReference() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { const string unknown = "refs/heads/dahlbyk/has/hawkeyes"; @@ -261,7 +265,7 @@ public void CanRemoveANonExistingReference() [Fact] public void ARemovedReferenceCannotBeLookedUp() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { const string refName = "refs/heads/test"; @@ -274,7 +278,7 @@ public void ARemovedReferenceCannotBeLookedUp() [Fact] public void RemovingAReferenceDecreasesTheRefsCount() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { const string refName = "refs/heads/test"; @@ -294,7 +298,8 @@ public void RemovingAReferenceDecreasesTheRefsCount() [Fact] public void RemoveWithEmptyNameThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Refs.Remove(string.Empty)); } @@ -303,7 +308,8 @@ public void RemoveWithEmptyNameThrows() [Fact] public void RemoveWithNullNameThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Refs.Remove((string)null)); Assert.Throws(() => repo.Refs.Remove((Reference)null)); @@ -313,7 +319,7 @@ public void RemoveWithNullNameThrows() [Fact] public void CanListAllReferencesEvenCorruptedOnes() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { CreateCorruptedDeadBeefHead(repo.Info.Path); @@ -327,7 +333,8 @@ public void CanListAllReferencesEvenCorruptedOnes() [Fact] public void CanResolveHeadByName() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var head = (SymbolicReference)repo.Refs.Head; Assert.NotNull(head); @@ -348,7 +355,8 @@ public void CanResolveHeadByName() [Fact] public void CanResolveReferenceToALightweightTag() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var lwTag = (DirectReference)repo.Refs["refs/tags/lw"]; Assert.NotNull(lwTag); @@ -362,7 +370,8 @@ public void CanResolveReferenceToALightweightTag() [Fact] public void CanResolveReferenceToAnAnnotatedTag() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var annTag = (DirectReference)repo.Refs["refs/tags/test"]; Assert.NotNull(annTag); @@ -376,7 +385,8 @@ public void CanResolveReferenceToAnAnnotatedTag() [Fact] public void CanResolveRefsByName() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var master = (DirectReference)repo.Refs["refs/heads/master"]; Assert.NotNull(master); @@ -390,7 +400,8 @@ public void CanResolveRefsByName() [Fact] public void ResolvingWithEmptyStringThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => { Reference head = repo.Refs[string.Empty]; }); } @@ -399,7 +410,8 @@ public void ResolvingWithEmptyStringThrows() [Fact] public void ResolvingWithNullThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => { Reference head = repo.Refs[null]; }); } @@ -409,7 +421,7 @@ public void ResolvingWithNullThrows() public void CanUpdateTargetOfADirectReference() { const string masterRef = "refs/heads/master"; - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { string sha = repo.Refs["refs/heads/test"].ResolveToDirectReference().Target.Sha; @@ -429,7 +441,7 @@ public void CanUpdateTargetOfADirectReference() public void CanUpdateTargetOfADirectReferenceWithAnAbbreviatedSha() { const string masterRef = "refs/heads/master"; - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { string sha = repo.Refs["refs/heads/test"].ResolveToDirectReference().Target.Sha; @@ -449,7 +461,7 @@ public void CanUpdateTargetOfADirectReferenceWithAnAbbreviatedSha() public void CanUpdateTargetOfASymbolicReference() { const string name = "refs/heads/unit_test"; - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { var newRef = (SymbolicReference)repo.Refs.Add(name, "refs/heads/master"); @@ -467,7 +479,7 @@ public void CanUpdateTargetOfASymbolicReference() [Fact] public void CanUpdateHeadWithARevparseSpec() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Branch test = repo.Branches["test"]; @@ -485,7 +497,7 @@ public void CanUpdateHeadWithARevparseSpec() [Fact] public void CanUpdateHeadWithEitherAnObjectIdOrAReference() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { EnableRefLog(repo); @@ -522,7 +534,7 @@ public void CanUpdateHeadWithEitherAnObjectIdOrAReference() [Fact] public void CanUpdateTargetOfADirectReferenceWithARevparseSpec() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { EnableRefLog(repo); @@ -553,7 +565,7 @@ public void CanUpdateTargetOfADirectReferenceWithARevparseSpec() public void UpdatingADirectRefWithSymbolFails() { const string name = "refs/heads/unit_test"; - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { var newRef = (SymbolicReference)repo.Refs.Add(name, "refs/heads/master"); @@ -570,7 +582,7 @@ public void UpdatingADirectRefWithSymbolFails() public void CanUpdateTargetOfADirectReferenceWithAShortReferenceNameAsARevparseSpec() { const string masterRef = "refs/heads/master"; - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Reference updatedMaster = repo.Refs.UpdateTarget(masterRef, "heads/test"); @@ -581,7 +593,8 @@ public void CanUpdateTargetOfADirectReferenceWithAShortReferenceNameAsARevparseS [Fact] public void UpdatingAReferenceTargetWithBadParametersFails() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Refs.UpdateTarget(string.Empty, "refs/heads/packed")); Assert.Throws(() => repo.Refs.UpdateTarget("refs/heads/master", string.Empty)); @@ -594,7 +607,8 @@ public void UpdatingAReferenceTargetWithBadParametersFails() [Fact] public void UpdatingADirectReferenceTargetWithARevparsePointingAtAnUnknownObjectFails() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Refs.UpdateTarget(repo.Refs["refs/heads/master"], "refs/heads/nope")); } @@ -603,7 +617,7 @@ public void UpdatingADirectReferenceTargetWithARevparsePointingAtAnUnknownObject [Fact] public void CanRenameAReferenceToADeeperReferenceHierarchy() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { const string newName = "refs/tags/test/deep"; @@ -617,7 +631,7 @@ public void CanRenameAReferenceToADeeperReferenceHierarchy() [Fact] public void CanRenameAReferenceToAUpperReferenceHierarchy() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { const string newName = "refs/heads/o/sole"; @@ -633,7 +647,7 @@ public void CanRenameAReferenceToAUpperReferenceHierarchy() [Fact] public void CanRenameAReferenceToADifferentReferenceHierarchy() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { const string oldName = "refs/tags/test"; @@ -656,7 +670,8 @@ public void CanRenameAReferenceToADifferentReferenceHierarchy() [Fact] public void RenamingANonExistingReferenceThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Refs.Rename("refs/tags/i-am-void", "refs/atic/tagtest")); } @@ -665,7 +680,7 @@ public void RenamingANonExistingReferenceThrows() [Fact] public void CanRenameAndOverWriteAExistingReference() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { const string oldName = "refs/heads/packed"; @@ -681,7 +696,8 @@ public void CanRenameAndOverWriteAExistingReference() [Fact] public void BlindlyOverwritingAExistingReferenceThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Refs.Rename("refs/heads/packed", "refs/heads/br2")); } @@ -690,7 +706,7 @@ public void BlindlyOverwritingAExistingReferenceThrows() [Fact] public void RenamingAReferenceDoesNotDecreaseTheRefsCount() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { const string oldName = "refs/tags/test"; @@ -712,7 +728,7 @@ public void RenamingAReferenceDoesNotDecreaseTheRefsCount() [Fact] public void CanLookupARenamedReference() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { const string oldName = "refs/tags/test"; @@ -728,7 +744,8 @@ public void CanLookupARenamedReference() [Fact] public void CanFilterReferencesWithAGlob() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Equal(13, repo.Refs.FromGlob("*").Count()); Assert.Equal(5, repo.Refs.FromGlob("refs/heads/*").Count()); @@ -750,17 +767,13 @@ public void CanFilterReferencesWithAGlob() [InlineData("/", false)] public void CanTellIfAReferenceIsValid(string refname, bool expectedResult) { - using (var repo = new Repository(BareTestRepoPath)) - { - Assert.Equal(expectedResult, Reference.IsValidName(refname)); - } + Assert.Equal(expectedResult, Reference.IsValidName(refname)); } [Fact] public void CanUpdateTheTargetOfASymbolicReferenceWithAnotherSymbolicReference() { - string repoPath = CloneBareTestRepo(); - + string repoPath = SandboxBareTestRepo(); using (var repo = new Repository(repoPath)) { Reference symbolicRef = repo.Refs.Add("refs/heads/unit_test", "refs/heads/master"); @@ -775,7 +788,8 @@ public void CanUpdateTheTargetOfASymbolicReferenceWithAnotherSymbolicReference() [Fact] public void LookingForLowerCaseHeadThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Refs["head"]); } @@ -789,14 +803,16 @@ private static T[] SortedRefs(IRepository repo, Func selector) [Fact] public void CanIdentifyReferenceKind() { - using (var repo = new Repository(StandardTestRepoWorkingDirPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { Assert.True(repo.Refs["refs/heads/master"].IsLocalBranch()); Assert.True(repo.Refs["refs/remotes/origin/master"].IsRemoteTrackingBranch()); Assert.True(repo.Refs["refs/tags/lw"].IsTag()); } - using (var repo = new Repository(BareTestRepoPath)) + path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.True(repo.Refs["refs/notes/commits"].IsNote()); } @@ -805,7 +821,8 @@ public void CanIdentifyReferenceKind() [Fact] public void CanQueryReachability() { - using (var repo = new Repository(StandardTestRepoWorkingDirPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { var result = repo.Refs.ReachableFrom( new[] { repo.Lookup("f8d44d7"), repo.Lookup("6dcf9bf") }); @@ -827,7 +844,8 @@ public void CanQueryReachability() [Fact] public void CanQueryReachabilityAmongASubsetOfreferences() { - using (var repo = new Repository(StandardTestRepoWorkingDirPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { var result = repo.Refs.ReachableFrom( repo.Refs.Where(r => r.IsTag()), @@ -847,7 +865,8 @@ public void CanQueryReachabilityAmongASubsetOfreferences() [Fact] public void CanHandleInvalidArguments() { - using (var repo = new Repository(StandardTestRepoWorkingDirPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Refs.ReachableFrom(null)); Assert.Throws(() => repo.Refs.ReachableFrom(null, repo.Commits.Take(2))); diff --git a/LibGit2Sharp.Tests/ReflogFixture.cs b/LibGit2Sharp.Tests/ReflogFixture.cs index 155ea5a73..9f1339893 100644 --- a/LibGit2Sharp.Tests/ReflogFixture.cs +++ b/LibGit2Sharp.Tests/ReflogFixture.cs @@ -13,8 +13,8 @@ public void CanReadReflog() { const int expectedReflogEntriesCount = 3; - - using (var repo = new Repository(StandardTestRepoWorkingDirPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { var reflog = repo.Refs.Log(repo.Refs.Head); @@ -34,7 +34,8 @@ public void CanReadReflog() [Fact] public void ReflogOfUnbornReferenceIsEmpty() { - using (var repo = new Repository(StandardTestRepoWorkingDirPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { Assert.Empty(repo.Refs.Log("refs/heads/toto")); } @@ -43,7 +44,8 @@ public void ReflogOfUnbornReferenceIsEmpty() [Fact] public void ReadingReflogOfInvalidReferenceNameThrows() { - using (var repo = new Repository(StandardTestRepoWorkingDirPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Refs.Log("toto").Count()); } @@ -112,7 +114,7 @@ public void CommitOnUnbornReferenceShouldCreateReflogEntryWithInitialTag() [Fact] public void CommitOnDetachedHeadShouldInsertReflogEntry() { - string repoPath = CloneStandardTestRepo(); + string repoPath = SandboxStandardTestRepo(); using (var repo = new Repository(repoPath)) { diff --git a/LibGit2Sharp.Tests/RemoteFixture.cs b/LibGit2Sharp.Tests/RemoteFixture.cs index 00d15a993..47d51390f 100644 --- a/LibGit2Sharp.Tests/RemoteFixture.cs +++ b/LibGit2Sharp.Tests/RemoteFixture.cs @@ -10,7 +10,8 @@ public class RemoteFixture : BaseFixture [Fact] public void CanGetRemoteOrigin() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Remote origin = repo.Network.Remotes["origin"]; Assert.NotNull(origin); @@ -23,7 +24,8 @@ public void CanGetRemoteOrigin() [Fact] public void GettingRemoteThatDoesntExistReturnsNull() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Null(repo.Network.Remotes["test"]); } @@ -32,7 +34,8 @@ public void GettingRemoteThatDoesntExistReturnsNull() [Fact] public void CanEnumerateTheRemotes() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { int count = 0; @@ -53,7 +56,7 @@ public void CanEnumerateTheRemotes() [InlineData(TagFetchMode.None)] public void CanSetTagFetchMode(TagFetchMode tagFetchMode) { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { const string name = "upstream"; @@ -73,7 +76,7 @@ public void CanSetTagFetchMode(TagFetchMode tagFetchMode) [Fact] public void CanSetRemoteUrl() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { const string name = "upstream"; @@ -94,7 +97,7 @@ public void CanSetRemoteUrl() [Fact] public void CanCheckEqualityOfRemote() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Remote oneOrigin = repo.Network.Remotes["origin"]; @@ -116,7 +119,7 @@ public void CanCheckEqualityOfRemote() [Fact] public void CreatingANewRemoteAddsADefaultRefSpec() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { const string name = "upstream"; @@ -139,7 +142,7 @@ public void CreatingANewRemoteAddsADefaultRefSpec() [Fact] public void CanAddANewRemoteWithAFetchRefSpec() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { const string name = "pull-requests"; @@ -160,7 +163,8 @@ public void CanAddANewRemoteWithAFetchRefSpec() [InlineData("/")] public void AddingARemoteWithAnInvalidNameThrows(string name) { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { const string url = "https://github.com/libgit2/libgit2sharp.git"; @@ -180,7 +184,8 @@ public void CanTellIfARemoteNameIsValid(string refname, bool expectedResult) [Fact] public void DoesNotThrowWhenARemoteHasNoUrlSet() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { var noUrlRemote = repo.Network.Remotes["no_url"]; Assert.NotNull(noUrlRemote); @@ -194,7 +199,7 @@ public void DoesNotThrowWhenARemoteHasNoUrlSet() [Fact] public void CreatingARemoteAddsADefaultFetchRefSpec() { - var path = CloneStandardTestRepo(); + var path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { var remote = repo.Network.Remotes.Add("one", "http://github.com/up/stream"); @@ -205,7 +210,7 @@ public void CreatingARemoteAddsADefaultFetchRefSpec() [Fact] public void CanCreateARemoteWithASpecifiedFetchRefSpec() { - var path = CloneStandardTestRepo(); + var path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { var remote = repo.Network.Remotes.Add("two", "http://github.com/up/stream", "+refs/heads/*:refs/remotes/grmpf/*"); @@ -216,7 +221,7 @@ public void CanCreateARemoteWithASpecifiedFetchRefSpec() [Fact] public void CanDeleteExistingRemote() { - var path = CloneStandardTestRepo(); + var path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Assert.NotNull(repo.Network.Remotes["origin"]); @@ -231,7 +236,8 @@ public void CanDeleteExistingRemote() [Fact] public void CanDeleteNonExistingRemote() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Null(repo.Network.Remotes["i_dont_exist"]); repo.Network.Remotes.Remove("i_dont_exist"); @@ -241,7 +247,7 @@ public void CanDeleteNonExistingRemote() [Fact] public void CanRenameExistingRemote() { - var path = CloneStandardTestRepo(); + var path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Assert.NotNull(repo.Network.Remotes["origin"]); @@ -261,7 +267,8 @@ public void CanRenameExistingRemote() [Fact] public void RenamingNonExistingRemoteThrows() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Throws(() => { @@ -273,7 +280,7 @@ public void RenamingNonExistingRemoteThrows() [Fact] public void ReportsRemotesWithNonDefaultRefSpecs() { - var path = CloneStandardTestRepo(); + var path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Assert.NotNull(repo.Network.Remotes["origin"]); @@ -295,7 +302,7 @@ public void ReportsRemotesWithNonDefaultRefSpecs() [Fact] public void DoesNotReportRemotesWithAlreadyExistingRefSpec() { - var path = CloneStandardTestRepo(); + var path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Assert.NotNull(repo.Network.Remotes["origin"]); @@ -318,7 +325,7 @@ public void CanNotRenameWhenRemoteWithSameNameExists() const string name = "upstream"; const string url = "https://github.com/libgit2/libgit2sharp.git"; - var path = CloneStandardTestRepo(); + var path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Assert.NotNull(repo.Network.Remotes["origin"]); diff --git a/LibGit2Sharp.Tests/RemoveFixture.cs b/LibGit2Sharp.Tests/RemoveFixture.cs index fb9f122e7..52a3aba0f 100644 --- a/LibGit2Sharp.Tests/RemoveFixture.cs +++ b/LibGit2Sharp.Tests/RemoveFixture.cs @@ -47,7 +47,7 @@ public class RemoveFixture : BaseFixture public void CanRemoveAnUnalteredFileFromTheIndexWithoutRemovingItFromTheWorkingDirectory( bool removeFromWorkdir, string filename, bool throws, FileStatus initialStatus, bool existsBeforeRemove, bool existsAfterRemove, FileStatus lastStatus) { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { int count = repo.Index.Count; @@ -83,7 +83,7 @@ public void RemovingAModifiedFileWhoseChangesHaveBeenPromotedToTheIndexAndWithAd { const string filename = "modified_staged_file.txt"; - var path = CloneStandardTestRepo(); + var path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { string fullpath = Path.Combine(repo.Info.WorkingDirectory, filename); @@ -101,7 +101,7 @@ public void RemovingAModifiedFileWhoseChangesHaveBeenPromotedToTheIndexAndWithAd [Fact] public void CanRemoveAFolderThroughUsageOfPathspecsForNewlyAddedFiles() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Stage(Touch(repo.Info.WorkingDirectory, "2/subdir1/2.txt", "whone")); @@ -122,7 +122,7 @@ public void CanRemoveAFolderThroughUsageOfPathspecsForNewlyAddedFiles() [Fact] public void CanRemoveAFolderThroughUsageOfPathspecsForFilesAlreadyInTheIndexAndInTheHEAD() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { int count = repo.Index.Count; @@ -142,7 +142,8 @@ public void RemovingAnUnknownFileWithLaxExplicitPathsValidationDoesntThrow(strin { for (int i = 0; i < 2; i++) { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Null(repo.Index[relativePath]); Assert.Equal(status, repo.RetrieveStatus(relativePath)); @@ -161,7 +162,8 @@ public void RemovingAnUnknownFileThrowsIfExplicitPath(string relativePath, FileS { for (int i = 0; i < 2; i++) { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Null(repo.Index[relativePath]); Assert.Equal(status, repo.RetrieveStatus(relativePath)); @@ -175,7 +177,8 @@ public void RemovingAnUnknownFileThrowsIfExplicitPath(string relativePath, FileS [Fact] public void RemovingFileWithBadParamsThrows() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Remove(string.Empty)); Assert.Throws(() => repo.Remove((string)null)); diff --git a/LibGit2Sharp.Tests/RepositoryFixture.cs b/LibGit2Sharp.Tests/RepositoryFixture.cs index c74804ffd..789e90460 100644 --- a/LibGit2Sharp.Tests/RepositoryFixture.cs +++ b/LibGit2Sharp.Tests/RepositoryFixture.cs @@ -37,7 +37,8 @@ public void CanCreateBareRepo() [Fact] public void AccessingTheIndexInABareRepoThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Index); } @@ -257,7 +258,8 @@ private static void AssertInitializedRepository(IRepository repo, string expecte [Fact] public void CanOpenBareRepositoryThroughAFullPathToTheGitDir() { - string path = Path.GetFullPath(BareTestRepoPath); + string relPath = SandboxBareTestRepo(); + string path = Path.GetFullPath(relPath); using (var repo = new Repository(path)) { Assert.NotNull(repo); @@ -268,7 +270,8 @@ public void CanOpenBareRepositoryThroughAFullPathToTheGitDir() [Fact] public void CanOpenStandardRepositoryThroughAWorkingDirPath() { - using (var repo = new Repository(StandardTestRepoWorkingDirPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { Assert.NotNull(repo); Assert.NotNull(repo.Info.WorkingDirectory); @@ -278,7 +281,8 @@ public void CanOpenStandardRepositoryThroughAWorkingDirPath() [Fact] public void OpeningStandardRepositoryThroughTheGitDirGuessesTheWorkingDirPath() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.NotNull(repo); Assert.NotNull(repo.Info.WorkingDirectory); @@ -288,7 +292,8 @@ public void OpeningStandardRepositoryThroughTheGitDirGuessesTheWorkingDirPath() [Fact] public void CanOpenRepository() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.NotNull(repo.Info.Path); Assert.Null(repo.Info.WorkingDirectory); @@ -313,7 +318,8 @@ public void OpeningRepositoryWithBadParamsThrows() [Fact] public void CanLookupACommitByTheNameOfABranch() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { GitObject gitObject = repo.Lookup("refs/heads/master"); Assert.NotNull(gitObject); @@ -324,7 +330,8 @@ public void CanLookupACommitByTheNameOfABranch() [Fact] public void CanLookupACommitByTheNameOfALightweightTag() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { GitObject gitObject = repo.Lookup("refs/tags/lw"); Assert.NotNull(gitObject); @@ -335,7 +342,8 @@ public void CanLookupACommitByTheNameOfALightweightTag() [Fact] public void CanLookupATagAnnotationByTheNameOfAnAnnotatedTag() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { GitObject gitObject = repo.Lookup("refs/tags/e90810b"); Assert.NotNull(gitObject); @@ -346,7 +354,8 @@ public void CanLookupATagAnnotationByTheNameOfAnAnnotatedTag() [Fact] public void CanLookupObjects() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.NotNull(repo.Lookup(commitSha)); Assert.NotNull(repo.Lookup(commitSha)); @@ -357,7 +366,8 @@ public void CanLookupObjects() [Fact] public void CanLookupSameObjectTwiceAndTheyAreEqual() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { GitObject commit = repo.Lookup(commitSha); GitObject commit2 = repo.Lookup(commitSha); @@ -369,7 +379,8 @@ public void CanLookupSameObjectTwiceAndTheyAreEqual() [Fact] public void LookupObjectByWrongShaReturnsNull() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Null(repo.Lookup(Constants.UnknownSha)); Assert.Null(repo.Lookup(Constants.UnknownSha)); @@ -379,7 +390,8 @@ public void LookupObjectByWrongShaReturnsNull() [Fact] public void LookupObjectByWrongTypeReturnsNull() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.NotNull(repo.Lookup(commitSha)); Assert.NotNull(repo.Lookup(commitSha)); @@ -390,7 +402,8 @@ public void LookupObjectByWrongTypeReturnsNull() [Fact] public void LookupObjectByUnknownReferenceNameReturnsNull() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Null(repo.Lookup("refs/heads/chopped/off")); Assert.Null(repo.Lookup(Constants.UnknownSha)); @@ -427,7 +440,8 @@ public void CanLookupWhithShortIdentifers() [Fact] public void CanLookupUsingRevparseSyntax() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Null(repo.Lookup("master^")); @@ -444,7 +458,8 @@ public void CanLookupUsingRevparseSyntax() [Fact] public void CanResolveAmbiguousRevparseSpecs() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var o1 = repo.Lookup("e90810b"); // This resolves to a tag Assert.Equal("7b4384978d2493e851f9cca7858815fac9b10980", o1.Sha); @@ -456,7 +471,8 @@ public void CanResolveAmbiguousRevparseSpecs() [Fact] public void LookingUpWithBadParamsThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Lookup(string.Empty)); Assert.Throws(() => repo.Lookup(string.Empty)); @@ -470,7 +486,8 @@ public void LookingUpWithBadParamsThrows() [Fact] public void LookingUpWithATooShortShaThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Lookup("e90")); } @@ -479,7 +496,8 @@ public void LookingUpWithATooShortShaThrows() [Fact] public void LookingUpAGitLinkThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Lookup("e90810b")); } @@ -516,27 +534,26 @@ public void CanDiscoverAStandardRepoGivenASubDirectoryOfTheRepoPath() [Fact] public void CanDiscoverAStandardRepoGivenTheWorkingDirPath() { - string path = Repository.Discover(StandardTestRepoWorkingDirPath); - Assert.Equal(Path.GetFullPath(StandardTestRepoPath + Path.DirectorySeparatorChar), path); + string path = Sandbox(StandardTestRepoWorkingDirPath); + + string found = Repository.Discover(path); + Assert.Equal(Path.GetFullPath(string.Format("{0}{1}.git{1}", path, Path.DirectorySeparatorChar)), found); } [Fact] public void DiscoverReturnsNullWhenNoRepoCanBeFound() { - string path = Path.GetTempFileName(); - string suffix = "." + Guid.NewGuid().ToString().Substring(0, 7); + string path = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); - SelfCleaningDirectory scd = BuildSelfCleaningDirectory(path + suffix); + SelfCleaningDirectory scd = BuildSelfCleaningDirectory(path); Directory.CreateDirectory(scd.RootedDirectoryPath); Assert.Null(Repository.Discover(scd.RootedDirectoryPath)); - - File.Delete(path); } [Fact] public void CanDetectIfTheHeadIsOrphaned() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { string branchName = repo.Head.CanonicalName; @@ -554,7 +571,7 @@ public void CanDetectIfTheHeadIsOrphaned() [Fact] public void QueryingTheRemoteForADetachedHeadBranchReturnsNull() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Checkout(repo.Head.Tip.Sha, new CheckoutOptions() { CheckoutModifiers = CheckoutModifiers.Force }); @@ -607,12 +624,14 @@ public void AccessingADeletedHeadThrows() [Fact] public void CanDetectShallowness() { - using (var repo = new Repository(ShallowTestRepoPath)) + var path = Sandbox(ShallowTestRepoPath); + using (var repo = new Repository(path)) { Assert.True(repo.Info.IsShallow); } - using (var repo = new Repository(StandardTestRepoPath)) + path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.False(repo.Info.IsShallow); } diff --git a/LibGit2Sharp.Tests/RepositoryOptionsFixture.cs b/LibGit2Sharp.Tests/RepositoryOptionsFixture.cs index e8177a292..eca6ff34d 100644 --- a/LibGit2Sharp.Tests/RepositoryOptionsFixture.cs +++ b/LibGit2Sharp.Tests/RepositoryOptionsFixture.cs @@ -31,7 +31,8 @@ public void CanOpenABareRepoAsIfItWasAStandardOne() var options = new RepositoryOptions { WorkingDirectoryPath = newWorkdir, IndexPath = newIndex }; - using (var repo = new Repository(BareTestRepoPath, options)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path, options)) { var st = repo.RetrieveStatus("1/branch_file.txt"); Assert.Equal(FileStatus.Missing, st); @@ -43,7 +44,8 @@ public void CanOpenABareRepoAsIfItWasAStandardOneWithANonExisitingIndexFile() { var options = new RepositoryOptions { WorkingDirectoryPath = newWorkdir, IndexPath = newIndex }; - using (var repo = new Repository(BareTestRepoPath, options)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path, options)) { var st = repo.RetrieveStatus("1/branch_file.txt"); Assert.Equal(FileStatus.Removed, st); @@ -53,7 +55,7 @@ public void CanOpenABareRepoAsIfItWasAStandardOneWithANonExisitingIndexFile() [Fact] public void CanProvideADifferentWorkDirToAStandardRepo() { - var path1 = CloneStandardTestRepo(); + var path1 = SandboxStandardTestRepo(); using (var repo = new Repository(path1)) { Assert.Equal(FileStatus.Unaltered, repo.RetrieveStatus("1/branch_file.txt")); @@ -61,7 +63,7 @@ public void CanProvideADifferentWorkDirToAStandardRepo() var options = new RepositoryOptions { WorkingDirectoryPath = newWorkdir }; - var path2 = CloneStandardTestRepo(); + var path2 = SandboxStandardTestRepo(); using (var repo = new Repository(path2, options)) { Assert.Equal(FileStatus.Missing, repo.RetrieveStatus("1/branch_file.txt")); @@ -71,7 +73,7 @@ public void CanProvideADifferentWorkDirToAStandardRepo() [Fact] public void CanProvideADifferentIndexToAStandardRepo() { - var path1 = CloneStandardTestRepo(); + var path1 = SandboxStandardTestRepo(); using (var repo = new Repository(path1)) { Assert.Equal(FileStatus.Untracked, repo.RetrieveStatus("new_untracked_file.txt")); @@ -85,7 +87,7 @@ public void CanProvideADifferentIndexToAStandardRepo() var options = new RepositoryOptions { IndexPath = newIndex }; - var path2 = CloneStandardTestRepo(); + var path2 = SandboxStandardTestRepo(); using (var repo = new Repository(path2, options)) { Assert.Equal(FileStatus.Added, repo.RetrieveStatus("new_untracked_file.txt")); @@ -95,14 +97,15 @@ public void CanProvideADifferentIndexToAStandardRepo() [Fact] public void OpeningABareRepoWithoutProvidingBothWorkDirAndIndexThrows() { - Assert.Throws(() => new Repository(BareTestRepoPath, new RepositoryOptions {IndexPath = newIndex})); - Assert.Throws(() => new Repository(BareTestRepoPath, new RepositoryOptions {WorkingDirectoryPath = newWorkdir})); + string path = SandboxBareTestRepo(); + Assert.Throws(() => new Repository(path, new RepositoryOptions {IndexPath = newIndex})); + Assert.Throws(() => new Repository(path, new RepositoryOptions {WorkingDirectoryPath = newWorkdir})); } [Fact] public void CanSneakAdditionalCommitsIntoAStandardRepoWithoutAlteringTheWorkdirOrTheIndex() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Branch head = repo.Head; @@ -163,7 +166,8 @@ public void CanProvideDifferentConfigurationFilesToARepository() SystemConfigurationLocation = systemLocation, }; - using (var repo = new Repository(BareTestRepoPath, options)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path, options)) { Assert.True(repo.Config.HasConfig(ConfigurationLevel.Global)); Assert.Equal(name, repo.Config.Get("user.name").Value); diff --git a/LibGit2Sharp.Tests/ResetHeadFixture.cs b/LibGit2Sharp.Tests/ResetHeadFixture.cs index c45e54b9e..807ae5baa 100644 --- a/LibGit2Sharp.Tests/ResetHeadFixture.cs +++ b/LibGit2Sharp.Tests/ResetHeadFixture.cs @@ -25,7 +25,7 @@ public void ResetANewlyInitializedRepositoryThrows(bool isBare) [Fact] public void SoftResetToTheHeadOfARepositoryDoesNotChangeTheTargetOfTheHead() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Branch oldHead = repo.Head; @@ -39,7 +39,7 @@ public void SoftResetToTheHeadOfARepositoryDoesNotChangeTheTargetOfTheHead() [Fact] public void SoftResetToAParentCommitChangesTheTargetOfTheHead() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { var headCommit = repo.Head.Tip; @@ -53,7 +53,7 @@ public void SoftResetToAParentCommitChangesTheTargetOfTheHead() [Fact] public void SoftResetSetsTheHeadToTheDereferencedCommitOfAChainedTag() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Tag tag = repo.Tags["test"]; @@ -65,7 +65,8 @@ public void SoftResetSetsTheHeadToTheDereferencedCommitOfAChainedTag() [Fact] public void ResettingWithBadParamsThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Reset(ResetMode.Soft, (string)null)); Assert.Throws(() => repo.Reset(ResetMode.Soft, (Commit)null)); @@ -204,7 +205,8 @@ public void MixedResetRefreshesTheIndex() [Fact] public void MixedResetInABareRepositoryThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Reset(ResetMode.Mixed)); } @@ -213,7 +215,8 @@ public void MixedResetInABareRepositoryThrows() [Fact] public void HardResetInABareRepositoryThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Reset(ResetMode.Hard)); } @@ -222,7 +225,7 @@ public void HardResetInABareRepositoryThrows() [Fact] public void HardResetUpdatesTheContentOfTheWorkingDirectory() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { var names = new DirectoryInfo(repo.Info.WorkingDirectory).GetFileSystemInfos().Select(fsi => fsi.Name).ToList(); diff --git a/LibGit2Sharp.Tests/ResetIndexFixture.cs b/LibGit2Sharp.Tests/ResetIndexFixture.cs index ebfdd20f5..a87c4ef23 100644 --- a/LibGit2Sharp.Tests/ResetIndexFixture.cs +++ b/LibGit2Sharp.Tests/ResetIndexFixture.cs @@ -32,7 +32,8 @@ public void ResetANewlyInitializedNonBareRepositoryThrows() [Fact] public void ResettingInABareRepositoryThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Reset()); } @@ -61,7 +62,7 @@ private static bool IsStaged(StatusEntry entry) [Fact] public void ResetTheIndexWithTheHeadUnstagesEverything() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { RepositoryStatus oldStatus = repo.RetrieveStatus(); @@ -82,7 +83,7 @@ public void ResetTheIndexWithTheHeadUnstagesEverything() [Fact] public void CanResetTheIndexToTheContentOfACommitWithCommittishAsArgument() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Reset("be3563a"); @@ -100,7 +101,7 @@ public void CanResetTheIndexToTheContentOfACommitWithCommittishAsArgument() [Fact] public void CanResetTheIndexToTheContentOfACommitWithCommitAsArgument() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Reset(repo.Lookup("be3563a")); @@ -118,7 +119,7 @@ public void CanResetTheIndexToTheContentOfACommitWithCommitAsArgument() [Fact] public void CanResetTheIndexToASubsetOfTheContentOfACommitWithCommittishAsArgument() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Reset("5b5b025", new[]{ "new.txt" }); @@ -131,7 +132,7 @@ public void CanResetTheIndexToASubsetOfTheContentOfACommitWithCommittishAsArgume [Fact] public void CanResetTheIndexToASubsetOfTheContentOfACommitWithCommitAsArgumentAndLaxUnmatchedExplicitPathsValidation() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Reset(repo.Lookup("5b5b025"), new[] { "new.txt", "non-existent-path-28.txt" }, @@ -145,7 +146,7 @@ public void CanResetTheIndexToASubsetOfTheContentOfACommitWithCommitAsArgumentAn [Fact] public void ResettingTheIndexToASubsetOfTheContentOfACommitWithCommitAsArgumentAndStrictUnmatchedPathspecsValidationThrows() { - using (var repo = new Repository(CloneStandardTestRepo())) + using (var repo = new Repository(SandboxStandardTestRepo())) { Assert.Throws(() => repo.Reset(repo.Lookup("5b5b025"), new[] { "new.txt", "non-existent-path-28.txt" }, new ExplicitPathsOptions())); @@ -155,7 +156,7 @@ public void ResettingTheIndexToASubsetOfTheContentOfACommitWithCommitAsArgumentA [Fact] public void CanResetTheIndexWhenARenameExists() { - using (var repo = new Repository(CloneStandardTestRepo())) + using (var repo = new Repository(SandboxStandardTestRepo())) { repo.Move("branch_file.txt", "renamed_branch_file.txt"); repo.Reset(repo.Lookup("32eab9c")); @@ -168,7 +169,7 @@ public void CanResetTheIndexWhenARenameExists() [Fact] public void CanResetSourceOfARenameInIndex() { - using (var repo = new Repository(CloneStandardTestRepo())) + using (var repo = new Repository(SandboxStandardTestRepo())) { repo.Move("branch_file.txt", "renamed_branch_file.txt"); @@ -189,7 +190,7 @@ public void CanResetSourceOfARenameInIndex() [Fact] public void CanResetTargetOfARenameInIndex() { - using (var repo = new Repository(CloneStandardTestRepo())) + using (var repo = new Repository(SandboxStandardTestRepo())) { repo.Move("branch_file.txt", "renamed_branch_file.txt"); diff --git a/LibGit2Sharp.Tests/RevertFixture.cs b/LibGit2Sharp.Tests/RevertFixture.cs index 7f60431f9..5c52cc6c7 100644 --- a/LibGit2Sharp.Tests/RevertFixture.cs +++ b/LibGit2Sharp.Tests/RevertFixture.cs @@ -17,7 +17,7 @@ public void CanRevert() const string revertBranchName = "refs/heads/revert"; const string revertedFile = "a.txt"; - string path = CloneRevertTestRepo(); + string path = SandboxRevertTestRepo(); using (var repo = new Repository(path)) { // Checkout the revert branch. @@ -64,7 +64,7 @@ public void CanRevertAndNotCommit() const string revertBranchName = "refs/heads/revert"; const string revertedFile = "a.txt"; - string path = CloneRevertTestRepo(); + string path = SandboxRevertTestRepo(); using (var repo = new Repository(path)) { string modifiedFileFullPath = Path.Combine(repo.Info.WorkingDirectory, revertedFile); @@ -108,7 +108,7 @@ public void RevertWithConflictDoesNotCommit() // and the file whose contents we expect to be reverted. const string revertBranchName = "refs/heads/revert"; - string path = CloneRevertTestRepo(); + string path = SandboxRevertTestRepo(); using (var repo = new Repository(path)) { // Checkout the revert branch. @@ -146,7 +146,7 @@ public void RevertWithFileConflictStrategyOption(CheckoutFileConflictStrategy co const string revertBranchName = "refs/heads/revert"; const string conflictedFilePath = "a.txt"; - string path = CloneRevertTestRepo(); + string path = SandboxRevertTestRepo(); using (var repo = new Repository(path)) { // Checkout the revert branch. @@ -198,7 +198,7 @@ public void RevertReportsCheckoutProgress() { const string revertBranchName = "refs/heads/revert"; - string repoPath = CloneRevertTestRepo(); + string repoPath = SandboxRevertTestRepo(); using (var repo = new Repository(repoPath)) { // Checkout the revert branch. @@ -223,7 +223,7 @@ public void RevertReportsCheckoutNotification() { const string revertBranchName = "refs/heads/revert"; - string repoPath = CloneRevertTestRepo(); + string repoPath = SandboxRevertTestRepo(); using (var repo = new Repository(repoPath)) { // Checkout the revert branch. @@ -263,7 +263,7 @@ public void RevertFindsRenames(bool? findRenames) const string expectedBlobId = "0ff3bbb9c8bba2291654cd64067fa417ff54c508"; const string modifiedFilePath = "d_renamed.txt"; - string repoPath = CloneRevertTestRepo(); + string repoPath = SandboxRevertTestRepo(); using (var repo = new Repository(repoPath)) { Branch currentBranch = repo.Checkout(revertBranchName); @@ -320,7 +320,7 @@ public void CanRevertMergeCommit(int mainline, string expectedId) const string revertBranchName = "refs/heads/revert_merge"; const string commitIdToRevert = "2747045"; - string repoPath = CloneRevertTestRepo(); + string repoPath = SandboxRevertTestRepo(); using (var repo = new Repository(repoPath)) { Branch branch = repo.Checkout(revertBranchName); @@ -379,7 +379,7 @@ public void CanNotRevertAMergeCommitWithoutSpecifyingTheMainlineBranch() const string revertBranchName = "refs/heads/revert_merge"; const string commitIdToRevert = "2747045"; - string repoPath = CloneRevertTestRepo(); + string repoPath = SandboxRevertTestRepo(); using (var repo = new Repository(repoPath)) { Branch branch = repo.Checkout(revertBranchName); @@ -400,7 +400,7 @@ public void RevertWithNothingToRevert(bool commitOnSuccess) // The branch name to perform the revert on const string revertBranchName = "refs/heads/revert"; - string path = CloneRevertTestRepo(); + string path = SandboxRevertTestRepo(); using (var repo = new Repository(path)) { // Checkout the revert branch. @@ -441,7 +441,7 @@ public void RevertOrphanedBranchThrows() // The branch name to perform the revert on const string revertBranchName = "refs/heads/revert"; - string path = CloneRevertTestRepo(); + string path = SandboxRevertTestRepo(); using (var repo = new Repository(path)) { // Checkout the revert branch. diff --git a/LibGit2Sharp.Tests/ShadowCopyFixture.cs b/LibGit2Sharp.Tests/ShadowCopyFixture.cs index 445a4ecd5..5eaf4dced 100644 --- a/LibGit2Sharp.Tests/ShadowCopyFixture.cs +++ b/LibGit2Sharp.Tests/ShadowCopyFixture.cs @@ -17,7 +17,7 @@ public void CanProbeForNativeBinariesFromAShadowCopiedAssembly() Assembly assembly = type.Assembly; // Build a new domain which will shadow copy assemblies - string cachePath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); + string cachePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); Directory.CreateDirectory(cachePath); var setup = new AppDomainSetup diff --git a/LibGit2Sharp.Tests/StageFixture.cs b/LibGit2Sharp.Tests/StageFixture.cs index a6173719e..679f20486 100644 --- a/LibGit2Sharp.Tests/StageFixture.cs +++ b/LibGit2Sharp.Tests/StageFixture.cs @@ -18,7 +18,7 @@ public class StageFixture : BaseFixture [InlineData("new_tracked_file.txt", FileStatus.Added, true, FileStatus.Added, true, 0)] public void CanStage(string relativePath, FileStatus currentStatus, bool doesCurrentlyExistInTheIndex, FileStatus expectedStatusOnceStaged, bool doesExistInTheIndexOnceStaged, int expectedIndexCountVariation) { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { int count = repo.Index.Count; @@ -36,7 +36,7 @@ public void CanStage(string relativePath, FileStatus currentStatus, bool doesCur [Fact] public void CanStageTheUpdationOfAStagedFile() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { int count = repo.Index.Count; @@ -62,7 +62,8 @@ public void CanStageTheUpdationOfAStagedFile() [InlineData("deleted_staged_file.txt", FileStatus.Removed)] public void StagingAnUnknownFileThrowsIfExplicitPath(string relativePath, FileStatus status) { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Null(repo.Index[relativePath]); Assert.Equal(status, repo.RetrieveStatus(relativePath)); @@ -76,7 +77,8 @@ public void StagingAnUnknownFileThrowsIfExplicitPath(string relativePath, FileSt [InlineData("deleted_staged_file.txt", FileStatus.Removed)] public void CanStageAnUnknownFileWithLaxUnmatchedExplicitPathsValidation(string relativePath, FileStatus status) { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Null(repo.Index[relativePath]); Assert.Equal(status, repo.RetrieveStatus(relativePath)); @@ -93,7 +95,8 @@ public void CanStageAnUnknownFileWithLaxUnmatchedExplicitPathsValidation(string [InlineData("deleted_staged_file.txt", FileStatus.Removed)] public void StagingAnUnknownFileWithLaxExplicitPathsValidationDoesntThrow(string relativePath, FileStatus status) { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Null(repo.Index[relativePath]); Assert.Equal(status, repo.RetrieveStatus(relativePath)); @@ -106,7 +109,7 @@ public void StagingAnUnknownFileWithLaxExplicitPathsValidationDoesntThrow(string [Fact] public void CanStageTheRemovalOfAStagedFile() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { int count = repo.Index.Count; @@ -132,7 +135,7 @@ public void CanStageTheRemovalOfAStagedFile() [InlineData("!bang/unit_test.txt")] public void CanStageANewFileInAPersistentManner(string filename) { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Assert.Equal(FileStatus.Nonexistent, repo.RetrieveStatus(filename)); @@ -167,7 +170,7 @@ public void CanStageANewFileWithAFullPath(bool ignorecase) //InconclusiveIf(() => IsFileSystemCaseSensitive && ignorecase, // "Skipping 'ignorecase = true' test on case-sensitive file system."); - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { @@ -204,7 +207,7 @@ private static void AssertStage(bool? ignorecase, IRepository repo, string path) [Fact] public void CanStageANewFileWithARelativePathContainingNativeDirectorySeparatorCharacters() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { int count = repo.Index.Count; @@ -227,7 +230,7 @@ public void CanStageANewFileWithARelativePathContainingNativeDirectorySeparatorC public void StagingANewFileWithAFullPathWhichEscapesOutOfTheWorkingDirThrows() { SelfCleaningDirectory scd = BuildSelfCleaningDirectory(); - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { string fullPath = Touch(scd.RootedDirectoryPath, "unit_test.txt", "some contents"); @@ -239,7 +242,8 @@ public void StagingANewFileWithAFullPathWhichEscapesOutOfTheWorkingDirThrows() [Fact] public void StagingFileWithBadParamsThrows() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Stage(string.Empty)); Assert.Throws(() => repo.Stage((string)null)); @@ -276,7 +280,7 @@ public void StagingFileWithBadParamsThrows() [InlineData("new_*file.txt", 1)] public void CanStageWithPathspec(string relativePath, int expectedIndexCountVariation) { - using (var repo = new Repository(CloneStandardTestRepo())) + using (var repo = new Repository(SandboxStandardTestRepo())) { int count = repo.Index.Count; @@ -289,7 +293,7 @@ public void CanStageWithPathspec(string relativePath, int expectedIndexCountVari [Fact] public void CanStageWithMultiplePathspecs() { - using (var repo = new Repository(CloneStandardTestRepo())) + using (var repo = new Repository(SandboxStandardTestRepo())) { int count = repo.Index.Count; @@ -304,7 +308,7 @@ public void CanStageWithMultiplePathspecs() [InlineData("ignored_folder/file.txt")] public void CanIgnoreIgnoredPaths(string path) { - using (var repo = new Repository(CloneStandardTestRepo())) + using (var repo = new Repository(SandboxStandardTestRepo())) { Touch(repo.Info.WorkingDirectory, ".gitignore", "ignored_file.txt\nignored_folder/\n"); Touch(repo.Info.WorkingDirectory, path, "This file is ignored."); @@ -320,7 +324,7 @@ public void CanIgnoreIgnoredPaths(string path) [InlineData("ignored_folder/file.txt")] public void CanStageIgnoredPaths(string path) { - using (var repo = new Repository(CloneStandardTestRepo())) + using (var repo = new Repository(SandboxStandardTestRepo())) { Touch(repo.Info.WorkingDirectory, ".gitignore", "ignored_file.txt\nignored_folder/\n"); Touch(repo.Info.WorkingDirectory, path, "This file is ignored."); diff --git a/LibGit2Sharp.Tests/StashFixture.cs b/LibGit2Sharp.Tests/StashFixture.cs index 14fc38449..c9f94064f 100644 --- a/LibGit2Sharp.Tests/StashFixture.cs +++ b/LibGit2Sharp.Tests/StashFixture.cs @@ -12,7 +12,7 @@ public class StashFixture : BaseFixture [Fact] public void CannotAddStashAgainstBareRepository() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { var stasher = Constants.Signature; @@ -24,7 +24,7 @@ public void CannotAddStashAgainstBareRepository() [Fact] public void CanAddAndRemoveStash() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { var stasher = Constants.Signature; @@ -83,7 +83,7 @@ public void CanAddAndRemoveStash() [Fact] public void AddingAStashWithNoMessageGeneratesADefaultOne() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { var stasher = Constants.Signature; @@ -102,7 +102,7 @@ public void AddingAStashWithNoMessageGeneratesADefaultOne() [Fact] public void AddStashWithBadParamsShouldThrows() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Assert.Throws(() => repo.Stashes.Add(default(Signature), options: StashModifiers.Default)); @@ -112,7 +112,7 @@ public void AddStashWithBadParamsShouldThrows() [Fact] public void StashingAgainstCleanWorkDirShouldReturnANullStash() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { var stasher = Constants.Signature; @@ -129,7 +129,7 @@ public void StashingAgainstCleanWorkDirShouldReturnANullStash() [Fact] public void CanStashWithoutOptions() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { var stasher = Constants.Signature; @@ -158,7 +158,7 @@ public void CanStashWithoutOptions() [Fact] public void CanStashAndKeepIndex() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { var stasher = Constants.Signature; @@ -179,7 +179,7 @@ public void CanStashAndKeepIndex() [Fact] public void CanStashIgnoredFiles() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { const string gitIgnore = ".gitignore"; @@ -209,7 +209,7 @@ public void CanStashIgnoredFiles() [InlineData(-42)] public void RemovingStashWithBadParamShouldThrow(int badIndex) { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Assert.Throws(() => repo.Stashes.Remove(badIndex)); @@ -219,7 +219,7 @@ public void RemovingStashWithBadParamShouldThrow(int badIndex) [Fact] public void CanGetStashByIndexer() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { var stasher = Constants.Signature; @@ -263,7 +263,8 @@ public void CanGetStashByIndexer() [InlineData(-42)] public void GettingStashWithBadIndexThrows(int badIndex) { - using (var repo = new Repository(StandardTestRepoWorkingDirPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Stashes[badIndex]); } @@ -274,7 +275,8 @@ public void GettingStashWithBadIndexThrows(int badIndex) [InlineData(42)] public void GettingAStashThatDoesNotExistReturnsNull(int bigIndex) { - using (var repo = new Repository(StandardTestRepoWorkingDirPath)) + string path = SandboxStandardTestRepo(); + using (var repo = new Repository(path)) { Assert.Null(repo.Stashes[bigIndex]); } diff --git a/LibGit2Sharp.Tests/StatusFixture.cs b/LibGit2Sharp.Tests/StatusFixture.cs index 35cfddda9..3e262e349 100644 --- a/LibGit2Sharp.Tests/StatusFixture.cs +++ b/LibGit2Sharp.Tests/StatusFixture.cs @@ -13,7 +13,8 @@ public class StatusFixture : BaseFixture [Fact] public void CanRetrieveTheStatusOfAFile() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { FileStatus status = repo.RetrieveStatus("new_tracked_file.txt"); Assert.Equal(FileStatus.Added, status); @@ -26,7 +27,7 @@ public void CanRetrieveTheStatusOfAFile() [InlineData(StatusShowOption.IndexOnly, FileStatus.Nonexistent)] public void CanLimitStatusToWorkDirOnly(StatusShowOption show, FileStatus expected) { - var clone = CloneStandardTestRepo(); + var clone = SandboxStandardTestRepo(); using (var repo = new Repository(clone)) { @@ -43,7 +44,7 @@ public void CanLimitStatusToWorkDirOnly(StatusShowOption show, FileStatus expect [InlineData(StatusShowOption.IndexOnly, FileStatus.Added)] public void CanLimitStatusToIndexOnly(StatusShowOption show, FileStatus expected) { - var clone = CloneStandardTestRepo(); + var clone = SandboxStandardTestRepo(); using (var repo = new Repository(clone)) { @@ -81,7 +82,7 @@ public void CanLimitStatusToIndexOnly(StatusShowOption show, FileStatus expected [InlineData("dir!/file.txt")] public void CanRetrieveTheStatusOfAnUntrackedFile(string filePath) { - var clone = CloneStandardTestRepo(); + var clone = SandboxStandardTestRepo(); using (var repo = new Repository(clone)) { @@ -95,7 +96,8 @@ public void CanRetrieveTheStatusOfAnUntrackedFile(string filePath) [Fact] public void RetrievingTheStatusOfADirectoryThrows() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Throws(() => { FileStatus status = repo.RetrieveStatus("1"); }); } @@ -104,7 +106,7 @@ public void RetrievingTheStatusOfADirectoryThrows() [Fact] public void CanRetrieveTheStatusOfTheWholeWorkingDirectory() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { const string file = "modified_staged_file.txt"; @@ -148,7 +150,7 @@ public void CanRetrieveTheStatusOfTheWholeWorkingDirectory() [Fact] public void CanRetrieveTheStatusOfRenamedFilesInWorkDir() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Touch(repo.Info.WorkingDirectory, "old_name.txt", @@ -177,7 +179,7 @@ public void CanRetrieveTheStatusOfRenamedFilesInWorkDir() [Fact] public void CanRetrieveTheStatusOfRenamedFilesInIndex() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { File.Move( @@ -315,7 +317,7 @@ public void RetrievingTheStatusOfAnEmptyRepositoryHonorsTheGitIgnoreDirectives() [Fact] public void RetrievingTheStatusOfTheRepositoryHonorsTheGitIgnoreDirectives() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { string relativePath = Path.Combine("1", "look-ma.txt"); @@ -457,7 +459,7 @@ public void RetrievingTheStatusOfTheRepositoryHonorsTheGitIgnoreDirectivesThroug { char dirSep = Path.DirectorySeparatorChar; - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Touch(repo.Info.WorkingDirectory, "bin/look-ma.txt", "I'm going to be ignored!"); @@ -490,7 +492,7 @@ public void RetrievingTheStatusOfTheRepositoryHonorsTheGitIgnoreDirectivesThroug [Fact] public void CanRetrieveStatusOfFilesInSubmodule() { - var path = CloneSubmoduleTestRepo(); + var path = SandboxSubmoduleTestRepo(); using (var repo = new Repository(path)) { string[] expected = new string[] { @@ -510,7 +512,7 @@ public void CanRetrieveStatusOfFilesInSubmodule() [Fact] public void CanExcludeStatusOfFilesInSubmodule() { - var path = CloneSubmoduleTestRepo(); + var path = SandboxSubmoduleTestRepo(); using (var repo = new Repository(path)) { string[] expected = new string[] { @@ -525,7 +527,7 @@ public void CanExcludeStatusOfFilesInSubmodule() [Fact] public void CanRetrieveTheStatusOfARelativeWorkingDirectory() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { const string file = "just_a_dir/other.txt"; @@ -547,7 +549,7 @@ public void CanRetrieveTheStatusOfARelativeWorkingDirectory() [Fact] public void CanRetrieveTheStatusOfMultiplePathSpec() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { const string file = "just_a_dir/other.txt"; @@ -565,7 +567,7 @@ public void CanRetrieveTheStatusOfMultiplePathSpec() [Fact] public void CanRetrieveTheStatusOfAGlobSpec() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { const string file = "just_a_dir/other.txt"; diff --git a/LibGit2Sharp.Tests/SubmoduleFixture.cs b/LibGit2Sharp.Tests/SubmoduleFixture.cs index e72b7b2e5..e66961dd5 100644 --- a/LibGit2Sharp.Tests/SubmoduleFixture.cs +++ b/LibGit2Sharp.Tests/SubmoduleFixture.cs @@ -12,7 +12,7 @@ public class SubmoduleFixture : BaseFixture [Fact] public void RetrievingSubmoduleForNormalDirectoryReturnsNull() { - var path = CloneSubmoduleTestRepo(); + var path = SandboxSubmoduleTestRepo(); using (var repo = new Repository(path)) { var submodule = repo.Submodules["just_a_dir"]; @@ -31,7 +31,7 @@ public void RetrievingSubmoduleForNormalDirectoryReturnsNull() [InlineData("sm_unchanged", SubmoduleStatus.InConfig | SubmoduleStatus.InHead | SubmoduleStatus.InIndex | SubmoduleStatus.InWorkDir)] public void CanRetrieveTheStatusOfASubmodule(string name, SubmoduleStatus expectedStatus) { - var path = CloneSubmoduleTestRepo(); + var path = SandboxSubmoduleTestRepo(); using (var repo = new Repository(path)) { var submodule = repo.Submodules[name]; @@ -55,7 +55,7 @@ public void CanRetrieveTheStatusOfASubmodule(string name, SubmoduleStatus expect [InlineData("sm_unchanged", "480095882d281ed676fe5b863569520e54a7d5c0", "480095882d281ed676fe5b863569520e54a7d5c0", "480095882d281ed676fe5b863569520e54a7d5c0")] public void CanRetrieveTheCommitIdsOfASubmodule(string name, string headId, string indexId, string workDirId) { - var path = CloneSubmoduleTestRepo(); + var path = SandboxSubmoduleTestRepo(); using (var repo = new Repository(path)) { var submodule = repo.Submodules[name]; @@ -92,7 +92,7 @@ public void CanEnumerateRepositorySubmodules() "sm_unchanged", }; - var path = CloneSubmoduleTestRepo(); + var path = SandboxSubmoduleTestRepo(); using (var repo = new Repository(path)) { var submodules = repo.Submodules.OrderBy(s => s.Name, StringComparer.Ordinal); @@ -111,7 +111,7 @@ public void CanStageChangeInSubmoduleViaIndexStage(string submodulePath, bool ap { submodulePath += appendPathSeparator ? Path.DirectorySeparatorChar : default(char?); - var path = CloneSubmoduleTestRepo(); + var path = SandboxSubmoduleTestRepo(); using (var repo = new Repository(path)) { var submodule = repo.Submodules[submodulePath]; @@ -134,7 +134,7 @@ public void CanStageChangeInSubmoduleViaIndexStageWithOtherPaths(string submodul { submodulePath += appendPathSeparator ? Path.DirectorySeparatorChar : default(char?); - var path = CloneSubmoduleTestRepo(); + var path = SandboxSubmoduleTestRepo(); using (var repo = new Repository(path)) { var submodule = repo.Submodules[submodulePath]; diff --git a/LibGit2Sharp.Tests/TagFixture.cs b/LibGit2Sharp.Tests/TagFixture.cs index bd008af34..e64fab770 100644 --- a/LibGit2Sharp.Tests/TagFixture.cs +++ b/LibGit2Sharp.Tests/TagFixture.cs @@ -20,7 +20,7 @@ public class TagFixture : BaseFixture [Fact] public void CanAddALightWeightTagFromSha() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Tag newTag = repo.Tags.Add("i_am_lightweight", commitE90810BSha); @@ -33,7 +33,7 @@ public void CanAddALightWeightTagFromSha() [Fact] public void CanAddALightWeightTagFromAGitObject() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { GitObject obj = repo.Lookup(commitE90810BSha); @@ -48,7 +48,7 @@ public void CanAddALightWeightTagFromAGitObject() [Fact] public void CanAddALightWeightTagFromAbbreviatedSha() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Tag newTag = repo.Tags.Add("i_am_lightweight", commitE90810BSha.Substring(0, 17)); @@ -60,7 +60,7 @@ public void CanAddALightWeightTagFromAbbreviatedSha() [Fact] public void CanAddALightweightTagFromABranchName() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Tag newTag = repo.Tags.Add("i_am_lightweight", "refs/heads/master"); @@ -72,7 +72,7 @@ public void CanAddALightweightTagFromABranchName() [Fact] public void CanAddALightweightTagFromARevparseSpec() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Tag newTag = repo.Tags.Add("i_am_lightweight", "master^1^2"); @@ -85,7 +85,7 @@ public void CanAddALightweightTagFromARevparseSpec() [Fact] public void CanAddAndOverwriteALightweightTag() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Tag newTag = repo.Tags.Add("e90810b", commitE90810BSha, true); @@ -97,7 +97,7 @@ public void CanAddAndOverwriteALightweightTag() [Fact] public void CanAddATagWithNameContainingASlash() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { const string lwTagName = "i/am/deep"; @@ -120,7 +120,7 @@ public void CanAddATagWithNameContainingASlash() [Fact] public void CreatingATagWithNameMatchingAnAlreadyExistingReferenceHierarchyThrows() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { repo.ApplyTag("i/am/deep"); @@ -132,7 +132,7 @@ public void CreatingATagWithNameMatchingAnAlreadyExistingReferenceHierarchyThrow [Fact] public void CanAddAnAnnotatedTagFromABranchName() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Tag newTag = repo.Tags.Add("unit_test", "refs/heads/master", signatureTim, "a new tag"); @@ -144,7 +144,7 @@ public void CanAddAnAnnotatedTagFromABranchName() [Fact] public void CanAddAnAnnotatedTagFromSha() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Tag newTag = repo.Tags.Add("unit_test", tagTestSha, signatureTim, "a new tag"); @@ -158,7 +158,7 @@ public void CanAddAnAnnotatedTagFromSha() [Fact] public void CanAddAnAnnotatedTagFromObject() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { GitObject obj = repo.Lookup(tagTestSha); @@ -173,7 +173,7 @@ public void CanAddAnAnnotatedTagFromObject() [Fact] public void CanAddAnAnnotatedTagFromARevparseSpec() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Tag newTag = repo.Tags.Add("unit_test", "master^1^2", signatureTim, "a new tag"); @@ -187,7 +187,7 @@ public void CanAddAnAnnotatedTagFromARevparseSpec() // Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L359) public void CanAddAnAnnotatedTagWithAnEmptyMessage() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Tag newTag = repo.ApplyTag("empty-annotated-tag", signatureNtk, string.Empty); @@ -200,7 +200,7 @@ public void CanAddAnAnnotatedTagWithAnEmptyMessage() [Fact] public void CanAddAndOverwriteAnAnnotatedTag() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Tag newTag = repo.Tags.Add("e90810b", tagTestSha, signatureTim, "a new tag", true); @@ -215,7 +215,7 @@ public void CreatingAnAnnotatedTagIsDeterministic() const string tagName = "nullTAGen"; const string tagMessage = "I've been tagged!"; - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Tag newTag = repo.Tags.Add(tagName, commitE90810BSha, signatureNtk, tagMessage); @@ -255,7 +255,8 @@ public void CreatingATagForHeadInAEmptyRepositoryThrows() // Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L42) public void CreatingATagForAnUnknowReferenceThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.ApplyTag("mytagnorev", "aaaaaaaaaaa")); } @@ -265,7 +266,8 @@ public void CreatingATagForAnUnknowReferenceThrows() // Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L42) public void CreatingATagForAnUnknowObjectIdThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.ApplyTag("mytagnorev", Constants.UnknownSha)); } @@ -275,7 +277,7 @@ public void CreatingATagForAnUnknowObjectIdThrows() // Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L48) public void CanAddATagForImplicitHead() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Tag tag = repo.ApplyTag("mytag"); @@ -291,7 +293,7 @@ public void CanAddATagForImplicitHead() [Fact] public void CanAddATagForImplicitHeadInDetachedState() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { repo.Checkout(repo.Head.Tip); @@ -312,7 +314,7 @@ public void CanAddATagForImplicitHeadInDetachedState() // Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L87) public void CreatingADuplicateTagThrows() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { repo.ApplyTag("mytag"); @@ -325,7 +327,8 @@ public void CreatingADuplicateTagThrows() // Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L90) public void CreatingATagWithANonValidNameShouldFail() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.ApplyTag("")); Assert.Throws(() => repo.ApplyTag(".othertag")); @@ -339,7 +342,7 @@ public void CreatingATagWithANonValidNameShouldFail() // Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L101) public void CanAddATagUsingHead() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Tag tag = repo.ApplyTag("mytag", "HEAD"); @@ -355,7 +358,7 @@ public void CanAddATagUsingHead() [Fact] public void CanAddATagPointingToATree() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Commit headCommit = repo.Head.Tip; @@ -375,7 +378,8 @@ public void CanAddATagPointingToATree() public void CanReadTagWithoutTagger() { // Not all tags have a tagger. - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Tag tag = repo.Tags["tag_without_tagger"]; @@ -393,7 +397,7 @@ public void CanReadTagWithoutTagger() [Fact] public void CanAddATagPointingToABlob() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { var blob = repo.Lookup("a823312"); @@ -411,7 +415,7 @@ public void CanAddATagPointingToABlob() [Fact] public void CreatingALightweightTagPointingToATagAnnotationGeneratesAnAnnotatedTagReusingThePointedAtTagAnnotation() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Tag annotatedTag = repo.Tags["e90810b"]; @@ -431,7 +435,7 @@ public void CreatingALightweightTagPointingToATagAnnotationGeneratesAnAnnotatedT [Fact] public void CanAddAnAnnotatedTagPointingToATagAnnotation() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Tag annotatedTag = repo.Tags["e90810b"]; @@ -450,7 +454,8 @@ public void CanAddAnAnnotatedTagPointingToATagAnnotation() [Fact] public void BlindlyCreatingALightweightTagOverAnExistingOneThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Tags.Add("e90810b", "refs/heads/br2")); } @@ -459,7 +464,8 @@ public void BlindlyCreatingALightweightTagOverAnExistingOneThrows() [Fact] public void BlindlyCreatingAnAnnotatedTagOverAnExistingOneThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Tags.Add("e90810b", "refs/heads/br2", signatureNtk, "a nice message")); } @@ -468,7 +474,8 @@ public void BlindlyCreatingAnAnnotatedTagOverAnExistingOneThrows() [Fact] public void AddTagWithADuplicateNameThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Tags.Add("test", tagTestSha, signatureTim, "message")); } @@ -477,7 +484,8 @@ public void AddTagWithADuplicateNameThrows() [Fact] public void AddTagWithEmptyNameThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Tags.Add(string.Empty, "refs/heads/master", signatureTim, "message")); } @@ -486,7 +494,8 @@ public void AddTagWithEmptyNameThrows() [Fact] public void AddTagWithEmptyTargetThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Tags.Add("test_tag", string.Empty, signatureTim, "message")); } @@ -495,7 +504,8 @@ public void AddTagWithEmptyTargetThrows() [Fact] public void AddTagWithNotExistingTargetThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Tags.Add("test_tag", Constants.UnknownSha, signatureTim, "message")); } @@ -504,7 +514,8 @@ public void AddTagWithNotExistingTargetThrows() [Fact] public void AddTagWithNullMessageThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Tags.Add("test_tag", "refs/heads/master", signatureTim, null)); } @@ -513,7 +524,8 @@ public void AddTagWithNullMessageThrows() [Fact] public void AddTagWithNullNameThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Tags.Add(null, "refs/heads/master", signatureTim, "message")); } @@ -522,7 +534,8 @@ public void AddTagWithNullNameThrows() [Fact] public void AddTagWithNullSignatureThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Tags.Add("test_tag", "refs/heads/master", null, "message")); } @@ -531,7 +544,8 @@ public void AddTagWithNullSignatureThrows() [Fact] public void AddTagWithNullTargetThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Tags.Add("test_tag", (GitObject)null, signatureTim, "message")); Assert.Throws(() => repo.Tags.Add("test_tag", (string)null, signatureTim, "message")); @@ -541,7 +555,7 @@ public void AddTagWithNullTargetThrows() [Fact] public void CanRemoveATagThroughItsName() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { repo.Tags.Remove("e90810b"); @@ -551,7 +565,7 @@ public void CanRemoveATagThroughItsName() [Fact] public void CanRemoveATagThroughItsCanonicalName() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { repo.Tags.Remove("refs/tags/e90810b"); @@ -561,7 +575,7 @@ public void CanRemoveATagThroughItsCanonicalName() [Fact] public void CanRemoveATag() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { Tag tag = repo.Tags["e90810b"]; @@ -572,7 +586,7 @@ public void CanRemoveATag() [Fact] public void ARemovedTagCannotBeLookedUp() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { const string tagName = "e90810b"; @@ -585,7 +599,7 @@ public void ARemovedTagCannotBeLookedUp() [Fact] public void RemovingATagDecreasesTheTagsCount() { - string path = CloneBareTestRepo(); + string path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { const string tagName = "e90810b"; @@ -606,7 +620,8 @@ public void RemovingATagDecreasesTheTagsCount() // Ported from cgit (https://github.com/git/git/blob/1c08bf50cfcf924094eca56c2486a90e2bf1e6e2/t/t7004-tag.sh#L108) public void RemovingAnUnknownTagShouldFail() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Tags.Remove("unknown-tag")); } @@ -615,7 +630,8 @@ public void RemovingAnUnknownTagShouldFail() [Fact] public void GetTagByNameWithBadParamsThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Tag tag; Assert.Throws(() => tag = repo.Tags[null]); @@ -626,7 +642,8 @@ public void GetTagByNameWithBadParamsThrows() [Fact] public void CanListTags() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Equal(expectedTags, SortedTags(repo.Tags, t => t.Name)); @@ -650,7 +667,8 @@ public void CanListAllTagsInAEmptyRepository() [Fact] public void CanLookupALightweightTag() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Tag tag = repo.Tags["lw"]; Assert.NotNull(tag); @@ -665,7 +683,8 @@ public void CanLookupALightweightTag() [Fact] public void CanLookupATagByItsCanonicalName() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Tag tag = repo.Tags["refs/tags/lw"]; Assert.NotNull(tag); @@ -683,7 +702,8 @@ public void CanLookupATagByItsCanonicalName() [Fact] public void CanLookupAnAnnotatedTag() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Tag tag = repo.Tags["e90810b"]; Assert.NotNull(tag); @@ -703,7 +723,8 @@ public void CanLookupAnAnnotatedTag() [Fact] public void LookupEmptyTagNameThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => { Tag t = repo.Tags[string.Empty]; }); } @@ -712,7 +733,8 @@ public void LookupEmptyTagNameThrows() [Fact] public void LookupNullTagNameThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { Assert.Throws(() => { Tag t = repo.Tags[null]; }); } diff --git a/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs b/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs index 39c897a4e..5482d2ae1 100644 --- a/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs +++ b/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs @@ -27,8 +27,6 @@ static BaseFixture() { // Do the set up in the static ctor so it only happens once SetUpTestEnvironment(); - - DirectoryHelper.DeleteSubdirectories(Constants.TemporaryReposPath); } public static string BareTestRepoPath { get; private set; } @@ -40,6 +38,7 @@ static BaseFixture() public static string MergeRenamesTestRepoWorkingDirPath { get; private set; } public static string RevertTestRepoWorkingDirPath { get; private set; } public static string SubmoduleTestRepoWorkingDirPath { get; private set; } + private static string SubmoduleTargetTestRepoWorkingDirPath { get; set; } public static DirectoryInfo ResourcesDirectory { get; private set; } public static bool IsFileSystemCaseSensitive { get; private set; } @@ -54,32 +53,25 @@ private static void SetUpTestEnvironment() { IsFileSystemCaseSensitive = IsFileSystemCaseSensitiveInternal(); - var source = new DirectoryInfo(@"../../Resources"); - ResourcesDirectory = new DirectoryInfo(string.Format(@"Resources/{0}", Guid.NewGuid())); - var parent = new DirectoryInfo(@"Resources"); - - if (parent.Exists) - { - DirectoryHelper.DeleteSubdirectories(parent.FullName); - } - - DirectoryHelper.CopyFilesRecursively(source, ResourcesDirectory); + const string sourceRelativePath = @"../../Resources"; + ResourcesDirectory = new DirectoryInfo(sourceRelativePath); // Setup standard paths to our test repositories - BareTestRepoPath = Path.Combine(ResourcesDirectory.FullName, "testrepo.git"); - StandardTestRepoWorkingDirPath = Path.Combine(ResourcesDirectory.FullName, "testrepo_wd"); - StandardTestRepoPath = Path.Combine(StandardTestRepoWorkingDirPath, ".git"); - ShallowTestRepoPath = Path.Combine(ResourcesDirectory.FullName, "shallow.git"); - MergedTestRepoWorkingDirPath = Path.Combine(ResourcesDirectory.FullName, "mergedrepo_wd"); - MergeRenamesTestRepoWorkingDirPath = Path.Combine(ResourcesDirectory.FullName, "mergerenames_wd"); - MergeTestRepoWorkingDirPath = Path.Combine(ResourcesDirectory.FullName, "merge_testrepo_wd"); - RevertTestRepoWorkingDirPath = Path.Combine(ResourcesDirectory.FullName, "revert_testrepo_wd"); - SubmoduleTestRepoWorkingDirPath = Path.Combine(ResourcesDirectory.FullName, "submodule_wd"); + BareTestRepoPath = Path.Combine(sourceRelativePath, "testrepo.git"); + StandardTestRepoWorkingDirPath = Path.Combine(sourceRelativePath, "testrepo_wd"); + StandardTestRepoPath = Path.Combine(StandardTestRepoWorkingDirPath, "dot_git"); + ShallowTestRepoPath = Path.Combine(sourceRelativePath, "shallow.git"); + MergedTestRepoWorkingDirPath = Path.Combine(sourceRelativePath, "mergedrepo_wd"); + MergeRenamesTestRepoWorkingDirPath = Path.Combine(sourceRelativePath, "mergerenames_wd"); + MergeTestRepoWorkingDirPath = Path.Combine(sourceRelativePath, "merge_testrepo_wd"); + RevertTestRepoWorkingDirPath = Path.Combine(sourceRelativePath, "revert_testrepo_wd"); + SubmoduleTestRepoWorkingDirPath = Path.Combine(sourceRelativePath, "submodule_wd"); + SubmoduleTargetTestRepoWorkingDirPath = Path.Combine(sourceRelativePath, "submodule_target_wd"); } private static bool IsFileSystemCaseSensitiveInternal() { - var mixedPath = Path.Combine(Constants.TemporaryReposPath, "mIxEdCase"); + var mixedPath = Path.Combine(Constants.TemporaryReposPath, "mIxEdCase-" + Path.GetRandomFileName()); if (Directory.Exists(mixedPath)) { @@ -120,43 +112,42 @@ protected SelfCleaningDirectory BuildSelfCleaningDirectory(string path) return new SelfCleaningDirectory(this, path); } - protected string CloneBareTestRepo() + protected string SandboxBareTestRepo() { - return Clone(BareTestRepoPath); + return Sandbox(BareTestRepoPath); } - protected string CloneStandardTestRepo() + protected string SandboxStandardTestRepo() { - return Clone(StandardTestRepoWorkingDirPath); + return Sandbox(StandardTestRepoWorkingDirPath); } - protected string CloneMergedTestRepo() + protected string SandboxMergedTestRepo() { - return Clone(MergedTestRepoWorkingDirPath); + return Sandbox(MergedTestRepoWorkingDirPath); } - protected string CloneMergeRenamesTestRepo() + protected string SandboxStandardTestRepoGitDir() { - return Clone(MergeRenamesTestRepoWorkingDirPath); + return Sandbox(Path.Combine(StandardTestRepoWorkingDirPath)); } - protected string CloneMergeTestRepo() + protected string SandboxMergeTestRepo() { - return Clone(MergeTestRepoWorkingDirPath); + return Sandbox(MergeTestRepoWorkingDirPath); } - protected string CloneRevertTestRepo() + protected string SandboxRevertTestRepo() { - return Clone(RevertTestRepoWorkingDirPath); + return Sandbox(RevertTestRepoWorkingDirPath); } - public string CloneSubmoduleTestRepo() + public string SandboxSubmoduleTestRepo() { - var submoduleTarget = Path.Combine(ResourcesDirectory.FullName, "submodule_target_wd"); - return Clone(SubmoduleTestRepoWorkingDirPath, submoduleTarget); + return Sandbox(SubmoduleTestRepoWorkingDirPath, SubmoduleTargetTestRepoWorkingDirPath); } - private string Clone(string sourceDirectoryPath, params string[] additionalSourcePaths) + protected string Sandbox(string sourceDirectoryPath, params string[] additionalSourcePaths) { var scd = BuildSelfCleaningDirectory(); var source = new DirectoryInfo(sourceDirectoryPath); diff --git a/LibGit2Sharp.Tests/TestHelpers/SelfCleaningDirectory.cs b/LibGit2Sharp.Tests/TestHelpers/SelfCleaningDirectory.cs index 1c292cbb3..5abc9365f 100644 --- a/LibGit2Sharp.Tests/TestHelpers/SelfCleaningDirectory.cs +++ b/LibGit2Sharp.Tests/TestHelpers/SelfCleaningDirectory.cs @@ -28,7 +28,7 @@ public SelfCleaningDirectory(IPostTestDirectoryRemover directoryRemover, string protected static string BuildTempPath() { - return Path.Combine(Constants.TemporaryReposPath, Guid.NewGuid().ToString().Substring(0, 8)); + return Path.Combine(Constants.TemporaryReposPath, Path.GetRandomFileName()); } } } diff --git a/LibGit2Sharp.Tests/TreeDefinitionFixture.cs b/LibGit2Sharp.Tests/TreeDefinitionFixture.cs index b43e6131d..2a7aba07c 100644 --- a/LibGit2Sharp.Tests/TreeDefinitionFixture.cs +++ b/LibGit2Sharp.Tests/TreeDefinitionFixture.cs @@ -18,7 +18,8 @@ public class TreeDefinitionFixture : BaseFixture [Fact] public void CanBuildATreeDefinitionFromATree() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { TreeDefinition td = TreeDefinition.From(repo.Head.Tip.Tree); Assert.NotNull(td); @@ -34,7 +35,8 @@ public void BuildingATreeDefinitionWithBadParamsThrows() [Fact] public void RequestingANonExistingEntryReturnsNull() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { TreeDefinition td = TreeDefinition.From(repo.Head.Tip.Tree); @@ -48,7 +50,8 @@ public void RequestingANonExistingEntryReturnsNull() [Fact] public void RequestingAnEntryWithBadParamsThrows() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { TreeDefinition td = TreeDefinition.From(repo.Head.Tip.Tree); @@ -70,7 +73,8 @@ public void RequestingAnEntryWithBadParamsThrows() [InlineData("1", "040000", TreeEntryTargetType.Tree, "7f76480d939dc401415927ea7ef25c676b8ddb8f")] public void CanRetrieveEntries(string path, string expectedAttributes, TreeEntryTargetType expectedType, string expectedSha) { - using (var repo = new Repository(BareTestRepoPath)) + string repoPath = SandboxBareTestRepo(); + using (var repo = new Repository(repoPath)) { TreeDefinition td = TreeDefinition.From(repo.Head.Tip.Tree); @@ -100,7 +104,8 @@ private static Mode ToMode(string expectedAttributes) [InlineData("1", "2/3")] public void CanAddAnExistingTreeEntryDefinition(string sourcePath, string targetPath) { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { TreeDefinition td = TreeDefinition.From(repo.Head.Tip.Tree); Assert.Null(td[targetPath]); @@ -121,7 +126,8 @@ public void CanAddAnExistingGitLinkTreeEntryDefinition() const string sourcePath = "sm_unchanged"; const string targetPath = "sm_from_td"; - using (var repo = new Repository(SubmoduleTestRepoWorkingDirPath)) + var path = SandboxSubmoduleTestRepo(); + using (var repo = new Repository(path)) { TreeDefinition td = TreeDefinition.From(repo.Head.Tip.Tree); Assert.Null(td[targetPath]); @@ -148,7 +154,8 @@ public void CanAddAnExistingGitLinkTreeEntryDefinition() [InlineData("1", "2/3")] public void CanAddAnExistingTreeEntry(string sourcePath, string targetPath) { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var tree = repo.Head.Tip.Tree; var td = TreeDefinition.From(tree); @@ -172,7 +179,8 @@ public void CanAddAnExistingGitLinkTreeEntry(string targetPath) { const string sourcePath = "sm_unchanged"; - using (var repo = new Repository(SubmoduleTestRepoWorkingDirPath)) + var path = SandboxSubmoduleTestRepo(); + using (var repo = new Repository(path)) { var tree = repo.Head.Tip.Tree; var td = TreeDefinition.From(tree); @@ -195,7 +203,8 @@ public void CanAddAnExistingGitLinkTreeEntry(string targetPath) [InlineData("45b983be36b73c0788dc9cbcb76cbb80fc7bb057", "another_one.txt")] public void CanAddAnExistingBlob(string blobSha, string targetPath) { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { TreeDefinition td = TreeDefinition.From(repo.Head.Tip.Tree); Assert.Null(td[targetPath]); @@ -218,7 +227,8 @@ public void CanAddAnExistingSubmodule() { const string submodulePath = "sm_unchanged"; - using (var repo = new Repository(SubmoduleTestRepoWorkingDirPath)) + var path = SandboxSubmoduleTestRepo(); + using (var repo = new Repository(path)) { var submodule = repo.Submodules[submodulePath]; Assert.NotNull(submodule); @@ -246,7 +256,8 @@ public void CanAddAnExistingTree() const string treeSha = "7f76480d939dc401415927ea7ef25c676b8ddb8f"; const string targetPath = "1/2"; - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { TreeDefinition td = TreeDefinition.From(repo.Head.Tip.Tree); @@ -271,7 +282,8 @@ public void CanReplaceAnExistingTreeWithABlob() const string blobSha = "a8233120f6ad708f843d861ce2b7228ec4e3dec6"; const string targetPath = "1"; - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { TreeDefinition td = TreeDefinition.From(repo.Head.Tip.Tree); Assert.Equal(TreeEntryTargetType.Tree, td[targetPath].TargetType); @@ -301,7 +313,8 @@ public void CanReplaceAnExistingBlobWithATree(string targetPath) { const string treeSha = "7f76480d939dc401415927ea7ef25c676b8ddb8f"; - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { TreeDefinition td = TreeDefinition.From(repo.Head.Tip.Tree); Assert.NotNull(td[targetPath]); @@ -327,7 +340,8 @@ public void CanReplaceAnExistingTreeWithAGitLink() var commitId = (ObjectId)"480095882d281ed676fe5b863569520e54a7d5c0"; const string targetPath = "just_a_dir"; - using (var repo = new Repository(SubmoduleTestRepoWorkingDirPath)) + var path = SandboxSubmoduleTestRepo(); + using (var repo = new Repository(path)) { TreeDefinition td = TreeDefinition.From(repo.Head.Tip.Tree); Assert.Equal(TreeEntryTargetType.Tree, td[targetPath].TargetType); @@ -353,7 +367,8 @@ public void CanReplaceAnExistingGitLinkWithATree() const string treeSha = "607d96653d4d0a4f733107f7890c2e67b55b620d"; const string targetPath = "sm_unchanged"; - using (var repo = new Repository(SubmoduleTestRepoWorkingDirPath)) + var path = SandboxSubmoduleTestRepo(); + using (var repo = new Repository(path)) { TreeDefinition td = TreeDefinition.From(repo.Head.Tip.Tree); Assert.NotNull(td[targetPath]); @@ -380,7 +395,8 @@ public void CanReplaceAnExistingBlobWithAGitLink() var commitId = (ObjectId)"480095882d281ed676fe5b863569520e54a7d5c0"; const string targetPath = "just_a_file"; - using (var repo = new Repository(SubmoduleTestRepoWorkingDirPath)) + var path = SandboxSubmoduleTestRepo(); + using (var repo = new Repository(path)) { TreeDefinition td = TreeDefinition.From(repo.Head.Tip.Tree); Assert.NotNull(td[targetPath]); @@ -403,7 +419,8 @@ public void CanReplaceAnExistingGitLinkWithABlob() const string blobSha = "42cfb95cd01bf9225b659b5ee3edcc78e8eeb478"; const string targetPath = "sm_unchanged"; - using (var repo = new Repository(SubmoduleTestRepoWorkingDirPath)) + var path = SandboxSubmoduleTestRepo(); + using (var repo = new Repository(path)) { TreeDefinition td = TreeDefinition.From(repo.Head.Tip.Tree); Assert.NotNull(td[targetPath]); @@ -427,7 +444,8 @@ public void CanReplaceAnExistingGitLinkWithABlob() [Fact] public void CanNotReplaceAnExistingTreeWithATreeBeingAssembled() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { TreeDefinition td = TreeDefinition.From(repo.Head.Tip.Tree); Assert.Equal(TreeEntryTargetType.Tree, td["1"].TargetType); @@ -446,7 +464,8 @@ public void ModifyingTheContentOfATreeSetsItsOidToNull() const string blobSha = "a8233120f6ad708f843d861ce2b7228ec4e3dec6"; const string targetPath = "1/another_branch_file.txt"; - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { TreeDefinition td = TreeDefinition.From(repo.Head.Tip.Tree); @@ -464,7 +483,8 @@ public void ModifyingTheContentOfATreeSetsItsOidToNull() [Fact] public void CanAddAnExistingBlobEntryWithAnExistingTree() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { TreeDefinition td = TreeDefinition.From(repo.Head.Tip.Tree); TreeEntryDefinition original = td["README"]; diff --git a/LibGit2Sharp.Tests/TreeFixture.cs b/LibGit2Sharp.Tests/TreeFixture.cs index ced6f2788..f57f14063 100644 --- a/LibGit2Sharp.Tests/TreeFixture.cs +++ b/LibGit2Sharp.Tests/TreeFixture.cs @@ -13,7 +13,8 @@ public class TreeFixture : BaseFixture [Fact] public void CanCompareTwoTreeEntries() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var tree = repo.Lookup(sha); TreeEntry treeEntry1 = tree["README"]; @@ -26,7 +27,8 @@ public void CanCompareTwoTreeEntries() [Fact] public void CanConvertEntryToBlob() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var tree = repo.Lookup(sha); TreeEntry treeEntry = tree["README"]; @@ -39,7 +41,8 @@ public void CanConvertEntryToBlob() [Fact] public void CanConvertEntryToTree() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var tree = repo.Lookup(sha); TreeEntry treeEntry = tree["1"]; @@ -52,7 +55,8 @@ public void CanConvertEntryToTree() [Fact] public void CanEnumerateBlobs() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var tree = repo.Lookup(sha); @@ -68,7 +72,8 @@ public void CanEnumerateBlobs() [Fact] public void CanEnumerateSubTrees() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var tree = repo.Lookup(sha); @@ -84,7 +89,8 @@ public void CanEnumerateSubTrees() [Fact] public void CanEnumerateTreeEntries() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var tree = repo.Lookup(sha); Assert.Equal(tree.Count, tree.Count()); @@ -96,7 +102,8 @@ public void CanEnumerateTreeEntries() [Fact] public void CanGetEntryByName() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var tree = repo.Lookup(sha); TreeEntry treeEntry = tree["README"]; @@ -108,7 +115,8 @@ public void CanGetEntryByName() [Fact] public void GettingAnUknownTreeEntryReturnsNull() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var tree = repo.Lookup(sha); TreeEntry treeEntry = tree["I-do-not-exist"]; @@ -119,7 +127,8 @@ public void GettingAnUknownTreeEntryReturnsNull() [Fact] public void CanGetEntryCountFromTree() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var tree = repo.Lookup(sha); Assert.Equal(4, tree.Count); @@ -129,7 +138,8 @@ public void CanGetEntryCountFromTree() [Fact] public void CanReadEntryAttributes() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var tree = repo.Lookup(sha); Assert.Equal(Mode.NonExecutableFile, tree["README"].Mode); @@ -139,7 +149,8 @@ public void CanReadEntryAttributes() [Fact] public void CanReadTheTreeData() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { var tree = repo.Lookup(sha); Assert.NotNull(tree); @@ -149,7 +160,8 @@ public void CanReadTheTreeData() [Fact] public void TreeDataIsPresent() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { GitObject tree = repo.Lookup(sha); Assert.NotNull(tree); @@ -159,7 +171,8 @@ public void TreeDataIsPresent() [Fact] public void CanRetrieveTreeEntryPath() { - using (var repo = new Repository(BareTestRepoPath)) + string path = SandboxBareTestRepo(); + using (var repo = new Repository(path)) { /* From a commit tree */ var commitTree = repo.Lookup("4c062a6").Tree; @@ -204,7 +217,7 @@ public void CanRetrieveTreeEntryPath() [Fact] public void CanParseSymlinkTreeEntries() { - var path = CloneBareTestRepo(); + var path = SandboxBareTestRepo(); using (var repo = new Repository(path)) { diff --git a/LibGit2Sharp.Tests/UnstageFixture.cs b/LibGit2Sharp.Tests/UnstageFixture.cs index a965187bf..b511d6513 100644 --- a/LibGit2Sharp.Tests/UnstageFixture.cs +++ b/LibGit2Sharp.Tests/UnstageFixture.cs @@ -13,7 +13,7 @@ public class UnstageFixture : BaseFixture [Fact] public void StagingANewVersionOfAFileThenUnstagingItRevertsTheBlobToTheVersionOfHead() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { int count = repo.Index.Count; @@ -40,7 +40,7 @@ public void StagingANewVersionOfAFileThenUnstagingItRevertsTheBlobToTheVersionOf [Fact] public void CanStageAndUnstageAnIgnoredFile() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { Touch(repo.Info.WorkingDirectory, ".gitignore", "*.ign" + Environment.NewLine); @@ -69,7 +69,7 @@ public void CanUnstage( string relativePath, FileStatus currentStatus, bool doesCurrentlyExistInTheIndex, FileStatus expectedStatusOnceStaged, bool doesExistInTheIndexOnceStaged, int expectedIndexCountVariation) { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { int count = repo.Index.Count; @@ -89,7 +89,7 @@ public void CanUnstage( [InlineData("where-am-I.txt", FileStatus.Nonexistent)] public void UnstagingUnknownPathsWithStrictUnmatchedExplicitPathsValidationThrows(string relativePath, FileStatus currentStatus) { - using (var repo = new Repository(CloneStandardTestRepo())) + using (var repo = new Repository(SandboxStandardTestRepo())) { Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath)); @@ -102,7 +102,7 @@ public void UnstagingUnknownPathsWithStrictUnmatchedExplicitPathsValidationThrow [InlineData("where-am-I.txt", FileStatus.Nonexistent)] public void CanUnstageUnknownPathsWithLaxUnmatchedExplicitPathsValidation(string relativePath, FileStatus currentStatus) { - using (var repo = new Repository(CloneStandardTestRepo())) + using (var repo = new Repository(SandboxStandardTestRepo())) { Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath)); @@ -114,7 +114,7 @@ public void CanUnstageUnknownPathsWithLaxUnmatchedExplicitPathsValidation(string [Fact] public void CanUnstageTheRemovalOfAFile() { - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { int count = repo.Index.Count; @@ -159,7 +159,7 @@ public void CanUnstageUntrackedFileAgainstAnOrphanedHead() [InlineData("where-am-I.txt", FileStatus.Nonexistent)] public void UnstagingUnknownPathsAgainstAnOrphanedHeadWithStrictUnmatchedExplicitPathsValidationThrows(string relativePath, FileStatus currentStatus) { - using (var repo = new Repository(CloneStandardTestRepo())) + using (var repo = new Repository(SandboxStandardTestRepo())) { repo.Refs.UpdateTarget("HEAD", "refs/heads/orphaned"); Assert.True(repo.Info.IsHeadUnborn); @@ -175,7 +175,7 @@ public void UnstagingUnknownPathsAgainstAnOrphanedHeadWithStrictUnmatchedExplici [InlineData("where-am-I.txt", FileStatus.Nonexistent)] public void CanUnstageUnknownPathsAgainstAnOrphanedHeadWithLaxUnmatchedExplicitPathsValidation(string relativePath, FileStatus currentStatus) { - using (var repo = new Repository(CloneStandardTestRepo())) + using (var repo = new Repository(SandboxStandardTestRepo())) { repo.Refs.UpdateTarget("HEAD", "refs/heads/orphaned"); Assert.True(repo.Info.IsHeadUnborn); @@ -192,7 +192,7 @@ public void CanUnstageUnknownPathsAgainstAnOrphanedHeadWithLaxUnmatchedExplicitP public void UnstagingANewFileWithAFullPathWhichEscapesOutOfTheWorkingDirThrows() { SelfCleaningDirectory scd = BuildSelfCleaningDirectory(); - string path = CloneStandardTestRepo(); + string path = SandboxStandardTestRepo(); using (var repo = new Repository(path)) { DirectoryInfo di = Directory.CreateDirectory(scd.DirectoryPath); @@ -225,7 +225,8 @@ public void UnstagingANewFileWithAFullPathWhichEscapesOutOfTheWorkingDirAgainstA [Fact] public void UnstagingFileWithBadParamsThrows() { - using (var repo = new Repository(StandardTestRepoPath)) + var path = SandboxStandardTestRepoGitDir(); + using (var repo = new Repository(path)) { Assert.Throws(() => repo.Unstage(string.Empty)); Assert.Throws(() => repo.Unstage((string)null)); @@ -237,7 +238,7 @@ public void UnstagingFileWithBadParamsThrows() [Fact] public void CanUnstageSourceOfARename() { - using (var repo = new Repository(CloneStandardTestRepo())) + using (var repo = new Repository(SandboxStandardTestRepo())) { repo.Move("branch_file.txt", "renamed_branch_file.txt"); @@ -258,7 +259,7 @@ public void CanUnstageSourceOfARename() [Fact] public void CanUnstageTargetOfARename() { - using (var repo = new Repository(CloneStandardTestRepo())) + using (var repo = new Repository(SandboxStandardTestRepo())) { repo.Move("branch_file.txt", "renamed_branch_file.txt"); @@ -278,7 +279,7 @@ public void CanUnstageTargetOfARename() [Fact] public void CanUnstageBothSidesOfARename() { - using (var repo = new Repository(CloneStandardTestRepo())) + using (var repo = new Repository(SandboxStandardTestRepo())) { repo.Move("branch_file.txt", "renamed_branch_file.txt"); repo.Unstage(new string[] { "branch_file.txt", "renamed_branch_file.txt" }); diff --git a/LibGit2Sharp.v2.ncrunchsolution b/LibGit2Sharp.v2.ncrunchsolution index bf2ebc9c1..9420cc077 100644 --- a/LibGit2Sharp.v2.ncrunchsolution +++ b/LibGit2Sharp.v2.ncrunchsolution @@ -1,8 +1,8 @@ 1 false - false - false + true + true UseDynamicAnalysis UseStaticAnalysis UseStaticAnalysis