diff options
Diffstat (limited to 'LibGit2Sharp.Tests')
-rw-r--r-- | LibGit2Sharp.Tests/ShadowCopyFixture.cs | 7 | ||||
-rw-r--r-- | LibGit2Sharp.Tests/TestHelpers/Constants.cs | 26 |
2 files changed, 26 insertions, 7 deletions
diff --git a/LibGit2Sharp.Tests/ShadowCopyFixture.cs b/LibGit2Sharp.Tests/ShadowCopyFixture.cs index 546b7670..5f57a800 100644 --- a/LibGit2Sharp.Tests/ShadowCopyFixture.cs +++ b/LibGit2Sharp.Tests/ShadowCopyFixture.cs @@ -17,7 +17,7 @@ namespace LibGit2Sharp.Tests Assembly assembly = type.Assembly; // Build a new domain which will shadow copy assemblies - string cachePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); + string cachePath = Path.Combine(Constants.TemporaryReposPath, Path.GetRandomFileName()); Directory.CreateDirectory(cachePath); var setup = new AppDomainSetup @@ -51,11 +51,6 @@ namespace LibGit2Sharp.Tests // ...but are currently loaded from different locations... string cachedAssemblyLocation = wrapper.AssemblyLocation; - if (cachedAssemblyLocation.StartsWith("/private")) - { - // On OS X, sometimes you get /private/var/… instead of /var/…, but they map to the same place. - cachedAssemblyLocation = cachedAssemblyLocation.Substring("/private".Length); - } Assert.NotEqual(sourceAssembly.Location, cachedAssemblyLocation); // ...that the assembly in the other domain is stored in the shadow copy cache... diff --git a/LibGit2Sharp.Tests/TestHelpers/Constants.cs b/LibGit2Sharp.Tests/TestHelpers/Constants.cs index 46f1d4e4..954ed6aa 100644 --- a/LibGit2Sharp.Tests/TestHelpers/Constants.cs +++ b/LibGit2Sharp.Tests/TestHelpers/Constants.cs @@ -1,10 +1,11 @@ using System; +using System.IO; namespace LibGit2Sharp.Tests.TestHelpers { public static class Constants { - public const string TemporaryReposPath = "TestRepos"; + public static readonly string TemporaryReposPath = BuildPath(); public const string UnknownSha = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"; public static readonly Identity Identity = new Identity("A. U. Thor", "thor@valhalla.asgard.com"); public static readonly Signature Signature = new Signature(Identity, new DateTimeOffset(2011, 06, 16, 10, 58, 27, TimeSpan.FromHours(2))); @@ -30,5 +31,28 @@ namespace LibGit2Sharp.Tests.TestHelpers { return null; } + + public static string BuildPath() + { + string tempPath; + + var unixPath = Type.GetType("Mono.Unix.UnixPath, Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756"); + + if (unixPath != null) + { + // We're running on Mono/*nix. Let's unwrap the path + tempPath = (string)unixPath.InvokeMember("GetCompleteRealPath", + System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.FlattenHierarchy | + System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Public, + null, unixPath, new object[] { Path.GetTempPath() }); + } + else + { + // We're running on .Net/Windows + tempPath = Path.GetTempPath(); + } + + return Path.Combine(tempPath, "LibGit2Sharp-TestRepos"); + } } } |