Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-04-10 14:02:46 +0300
committernulltoken <emeric.fermas@gmail.com>2015-04-14 18:57:02 +0300
commit5e8f6abbb0cc06e3b65eedae622f793e672c30a1 (patch)
treee2a84e7b68f5b799d720282b667da5a435a6d829 /LibGit2Sharp.Tests
parent3de74b0511790253107b09d7c68406f6cea29e92 (diff)
Sandbox test repositories in TMP
Diffstat (limited to 'LibGit2Sharp.Tests')
-rw-r--r--LibGit2Sharp.Tests/ShadowCopyFixture.cs7
-rw-r--r--LibGit2Sharp.Tests/TestHelpers/Constants.cs26
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");
+ }
}
}