Skip to content

Commit

Permalink
Add meaningful message when an external process prevents tests cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
yorah committed May 25, 2012
1 parent 1c1f012 commit d0f541b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions LibGit2Sharp.Tests/TestHelpers/DirectoryHelper.cs
@@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;

namespace LibGit2Sharp.Tests.TestHelpers
{
Expand Down Expand Up @@ -46,7 +47,19 @@ public static void DeleteDirectory(string directoryPath)
}

File.SetAttributes(directoryPath, FileAttributes.Normal);
Directory.Delete(directoryPath, false);
try
{
Directory.Delete(directoryPath, false);
}
catch (IOException ex)
{
throw new IOException(string.Format("{0}The directory '{1}' could not be deleted!" +
"{0}Most of the time, this is due to an external process accessing the files in the temporary repositories created during the test runs, and keeping a handle on the directory, thus preventing the deletion of those files." +
"{0}Known and common causes include:" +
"{0}- Windows Search Indexer (go to the Indexing Options, in the Windows Control Panel, and exclude the bin folder of LibGit2Sharp.Tests)" +
"{0}- Antivirus (exclude the bin folder of LibGit2Sharp.Tests from the paths scanned by your real-time antivirus){0}",
Environment.NewLine, Path.GetFullPath(directoryPath)), ex);
}
}
}
}

0 comments on commit d0f541b

Please sign in to comment.