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:
authorMarius Ungureanu <marius.ungureanu@xamarin.com>2014-12-06 15:49:10 +0300
committernulltoken <emeric.fermas@gmail.com>2014-12-07 20:49:56 +0300
commit133505305a4b5d7938e70f125117a872739e474e (patch)
tree15b2e130e7b02ad4baa3dc10b219a0cb919a867b /LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
parentbf464cf8a99285abba628a275f682b3d6208d5f0 (diff)
Improve tracking toolset of improperly released unmanaged handles
Diffstat (limited to 'LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs')
-rw-r--r--LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs23
1 files changed, 19 insertions, 4 deletions
diff --git a/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs b/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
index dd2ab2c3..39c897a4 100644
--- a/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
+++ b/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
@@ -16,6 +16,13 @@ namespace LibGit2Sharp.Tests.TestHelpers
{
private readonly List<string> directories = new List<string>();
+#if LEAKS_IDENTIFYING
+ public BaseFixture()
+ {
+ LeaksContainer.Clear();
+ }
+#endif
+
static BaseFixture()
{
// Do the set up in the static ctor so it only happens once
@@ -190,14 +197,22 @@ namespace LibGit2Sharp.Tests.TestHelpers
public virtual void Dispose()
{
-#if LEAKS
- GC.Collect();
-#endif
-
foreach (string directory in directories)
{
DirectoryHelper.DeleteDirectory(directory);
}
+
+#if LEAKS_IDENTIFYING
+ GC.Collect();
+ GC.WaitForPendingFinalizers();
+
+ if (LeaksContainer.TypeNames.Any())
+ {
+ Assert.False(true, string.Format("Some handles of the following types haven't been properly released: {0}.{1}"
+ + "In order to get some help fixing those leaks, uncomment the define LEAKS_TRACKING in SafeHandleBase.cs{1}"
+ + "and run the tests locally.", string.Join(", ", LeaksContainer.TypeNames), Environment.NewLine));
+ }
+#endif
}
protected static void InconclusiveIf(Func<bool> predicate, string message)