From 3561e612025f82cc016242dc72b6f6cdf491552d Mon Sep 17 00:00:00 2001 From: Nathan Heskew Date: Tue, 16 Nov 2010 13:22:25 -0800 Subject: [PATCH] Cleaning up exceptions being thrown when the spec test web (app) host cleans up after itself --HG-- branch : dev --- src/Orchard.Specs/Bindings/WebAppHosting.cs | 8 ++++---- src/Orchard.Specs/Hosting/WebHost.cs | 9 ++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Orchard.Specs/Bindings/WebAppHosting.cs b/src/Orchard.Specs/Bindings/WebAppHosting.cs index 41ff6f62e..2d2222dfc 100644 --- a/src/Orchard.Specs/Bindings/WebAppHosting.cs +++ b/src/Orchard.Specs/Bindings/WebAppHosting.cs @@ -31,14 +31,14 @@ namespace Orchard.Specs.Bindings { [BeforeTestRun] public static void BeforeTestRun() { - if ( _orchardTemp.Exists ) { - _orchardTemp.Delete(true).CreateDirectory(); - } + try { _orchardTemp.Delete(true).CreateDirectory(); } catch {} } [AfterTestRun] public static void AfterTestRun() { - _orchardTemp.Delete(true); // <- try to clear any stragglers on the way out + try { + _orchardTemp.Delete(true); // <- try to clear any stragglers on the way out + } catch {} } [AfterScenario] diff --git a/src/Orchard.Specs/Hosting/WebHost.cs b/src/Orchard.Specs/Hosting/WebHost.cs index d2158b64b..38e2a97ab 100644 --- a/src/Orchard.Specs/Hosting/WebHost.cs +++ b/src/Orchard.Specs/Hosting/WebHost.cs @@ -18,17 +18,16 @@ namespace Orchard.Specs.Hosting { } void WebHostCleanup(object sender, EventArgs e) { - _tempSite.Delete(true); // <- try to clean up after the appdomain unloads (still not guaranteed to get everything - probably overkill - might go away) + try { + _tempSite.Delete(true); // <- try to clean up after the appdomain unloads (still not guaranteed to get everything - probably overkill - might go away) + } catch{} } public void Initialize(string templateName, string virtualDirectory) { var baseDir = Path.Get(AppDomain.CurrentDomain.BaseDirectory); _tempSite = Path.Get(_orchardTemp).Combine(System.IO.Path.GetRandomFileName()); - if(_tempSite.Exists) { - _tempSite.Delete(); - } - + try { _tempSite.Delete(); } catch {} _tempSite.CreateDirectory(); // Trying the two known relative paths to the Orchard.Web directory.