From ff09773a3b348ef8dde5139a03db5b9494d312e2 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sat, 19 Jan 2013 12:59:36 -0800 Subject: [PATCH] added parallel test execution support for ncrunch. --- NzbDrone.Core.Test/CentralDispatchFixture.cs | 4 ++- NzbDrone.Core.Test/Framework/TestDbHelper.cs | 11 +++++--- NzbDrone.Core.Test/NzbDrone.Core.Test.csproj | 4 +++ .../NzbDrone.Core.Test.ncrunchproject | 5 ++++ NzbDrone.Core.Test/packages.config | 1 + NzbDrone.Core/NzbDrone.Core.ncrunchproject | 6 +++-- .../NzbDrone.Services.Tests.ncrunchproject | 10 +++++-- NzbDrone.Test.Common/TestBase.cs | 26 ++++++++++++++----- .../NzbDrone.Web.UI.Automation.ncrunchproject | 4 +++ NzbDrone.Web/NzbDrone.Web.ncrunchproject | 6 +++-- NzbDrone.ncrunchsolution | 4 +-- .../ServiceInstall.ncrunchproject | 6 +++-- .../ServiceUninstall.ncrunchproject | 6 +++-- 13 files changed, 70 insertions(+), 23 deletions(-) diff --git a/NzbDrone.Core.Test/CentralDispatchFixture.cs b/NzbDrone.Core.Test/CentralDispatchFixture.cs index a86f49bef..5d90df06a 100644 --- a/NzbDrone.Core.Test/CentralDispatchFixture.cs +++ b/NzbDrone.Core.Test/CentralDispatchFixture.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using Autofac; using FluentAssertions; +using NCrunch.Framework; using NUnit.Framework; using NzbDrone.Core.Jobs; using NzbDrone.Core.Providers; @@ -15,6 +16,7 @@ using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test { [TestFixture] + [ExclusivelyUses("REAL_LOG_FILE")] class CentralDispatchFixture : CoreTest { readonly IList indexers = typeof(CentralDispatch).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(IndexerBase))).Select(c => c.ToString()).ToList(); @@ -120,7 +122,7 @@ namespace NzbDrone.Core.Test [Test] public void quality_profile_initialized() { - kernel.Resolve().All().Should().HaveCount(4); + kernel.Resolve().All().Should().HaveCount(2); } [Test] diff --git a/NzbDrone.Core.Test/Framework/TestDbHelper.cs b/NzbDrone.Core.Test/Framework/TestDbHelper.cs index 36e29301e..3be24eb44 100644 --- a/NzbDrone.Core.Test/Framework/TestDbHelper.cs +++ b/NzbDrone.Core.Test/Framework/TestDbHelper.cs @@ -16,7 +16,12 @@ namespace NzbDrone.Core.Test.Framework { internal static class TestDbHelper { - private const string DB_TEMPLATE_NAME = "_dbtemplate.sdf"; + private static readonly string dbTemplateName; + + static TestDbHelper() + { + dbTemplateName = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()) + ".sdf"; + } internal static string ConnectionString { get; private set; } @@ -30,7 +35,7 @@ namespace NzbDrone.Core.Test.Framework fileName = Guid.NewGuid() + ".sdf"; } - File.Copy(DB_TEMPLATE_NAME, fileName); + File.Copy(dbTemplateName, fileName); ConnectionString = ConnectionFactory.GetConnectionString(fileName); @@ -46,7 +51,7 @@ namespace NzbDrone.Core.Test.Framework internal static void CreateDataBaseTemplate() { Console.WriteLine("Creating an empty PetaPoco database"); - var connectionString = ConnectionFactory.GetConnectionString(DB_TEMPLATE_NAME); + var connectionString = ConnectionFactory.GetConnectionString(dbTemplateName); var database = ConnectionFactory.GetPetaPocoDb(connectionString); database.Dispose(); } diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 3c69d05e3..9a53a65ae 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -95,6 +95,10 @@ ..\packages\Moq.4.0.10827\lib\NET40\Moq.dll + + True + ..\packages\NCrunch.Framework.1.43.0.23\lib\net35\NCrunch.Framework.dll + False ..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.ncrunchproject b/NzbDrone.Core.Test/NzbDrone.Core.Test.ncrunchproject index 35a316e01..9812b56a3 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.ncrunchproject +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.ncrunchproject @@ -14,6 +14,7 @@ true 60000 + AutoDetect @@ -26,5 +27,9 @@ NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests.ImportFileFixture.import_unparsable_file_should_skip + + NzbDrone\.Core\.Test\.Integeration\.ServiceIntegerationFixture\..* + + PostBuildEventDisabled \ No newline at end of file diff --git a/NzbDrone.Core.Test/packages.config b/NzbDrone.Core.Test/packages.config index b65271bdb..cba15327e 100644 --- a/NzbDrone.Core.Test/packages.config +++ b/NzbDrone.Core.Test/packages.config @@ -8,6 +8,7 @@ + diff --git a/NzbDrone.Core/NzbDrone.Core.ncrunchproject b/NzbDrone.Core/NzbDrone.Core.ncrunchproject index 8641d3614..73e1ebbb9 100644 --- a/NzbDrone.Core/NzbDrone.Core.ncrunchproject +++ b/NzbDrone.Core/NzbDrone.Core.ncrunchproject @@ -13,7 +13,9 @@ true true 60000 - - + + + AutoDetect + PostBuildEventDisabled \ No newline at end of file diff --git a/NzbDrone.Services/NzbDrone.Services.Tests/NzbDrone.Services.Tests.ncrunchproject b/NzbDrone.Services/NzbDrone.Services.Tests/NzbDrone.Services.Tests.ncrunchproject index 8641d3614..f9f75a797 100644 --- a/NzbDrone.Services/NzbDrone.Services.Tests/NzbDrone.Services.Tests.ncrunchproject +++ b/NzbDrone.Services/NzbDrone.Services.Tests/NzbDrone.Services.Tests.ncrunchproject @@ -13,7 +13,13 @@ true true 60000 - - + + + AutoDetect + + + .* + + \ No newline at end of file diff --git a/NzbDrone.Test.Common/TestBase.cs b/NzbDrone.Test.Common/TestBase.cs index a5801995b..2e8fcb09d 100644 --- a/NzbDrone.Test.Common/TestBase.cs +++ b/NzbDrone.Test.Common/TestBase.cs @@ -31,7 +31,7 @@ namespace NzbDrone.Test.Common protected Mock MockedRestProvider { get; private set; } - protected string VirtualPath + private string VirtualPath { get { @@ -42,9 +42,15 @@ namespace NzbDrone.Test.Common } } + + protected string TempFolder { get; private set; } + [SetUp] public void TestBaseSetup() { + + TempFolder = Path.Combine(Directory.GetCurrentDirectory(), "_temp_" + DateTime.Now.Ticks); + MockedRestProvider = new Mock(); ReportingService.RestProvider = MockedRestProvider.Object; ReportingService.SetupExceptronDriver(); @@ -62,6 +68,18 @@ namespace NzbDrone.Test.Common public void TestBaseTearDown() { _mocker = null; + + try + { + if (Directory.Exists(TempFolder)) + { + Directory.Delete(TempFolder, true); + } + } + catch (Exception) + { + } + } protected void WithStrictMocker() @@ -80,12 +98,6 @@ namespace NzbDrone.Test.Common .Returns(VirtualPath); } - - protected string TempFolder - { - get { return Path.Combine(Directory.GetCurrentDirectory(), "temp"); } - } - protected string GetTestFilePath(string fileName) { return Path.Combine(@".\Files\", fileName); diff --git a/NzbDrone.Web.UI.Test/NzbDrone.Web.UI.Automation.ncrunchproject b/NzbDrone.Web.UI.Test/NzbDrone.Web.UI.Automation.ncrunchproject index 53613377d..f74e5814a 100644 --- a/NzbDrone.Web.UI.Test/NzbDrone.Web.UI.Automation.ncrunchproject +++ b/NzbDrone.Web.UI.Test/NzbDrone.Web.UI.Automation.ncrunchproject @@ -14,6 +14,7 @@ true 60000 + AutoDetect @@ -29,5 +30,8 @@ NzbDrone.Web.UI.Automation.BasicPageFixture.SettingsPage + + .* + \ No newline at end of file diff --git a/NzbDrone.Web/NzbDrone.Web.ncrunchproject b/NzbDrone.Web/NzbDrone.Web.ncrunchproject index 8641d3614..73e1ebbb9 100644 --- a/NzbDrone.Web/NzbDrone.Web.ncrunchproject +++ b/NzbDrone.Web/NzbDrone.Web.ncrunchproject @@ -13,7 +13,9 @@ true true 60000 - - + + + AutoDetect + PostBuildEventDisabled \ No newline at end of file diff --git a/NzbDrone.ncrunchsolution b/NzbDrone.ncrunchsolution index 659c51903..13efc6321 100644 --- a/NzbDrone.ncrunchsolution +++ b/NzbDrone.ncrunchsolution @@ -1,8 +1,8 @@ 1 True - false - false + true + true UseDynamicAnalysis Disabled Disabled diff --git a/ServiceHelpers/ServiceInstall/ServiceInstall.ncrunchproject b/ServiceHelpers/ServiceInstall/ServiceInstall.ncrunchproject index 8641d3614..73e1ebbb9 100644 --- a/ServiceHelpers/ServiceInstall/ServiceInstall.ncrunchproject +++ b/ServiceHelpers/ServiceInstall/ServiceInstall.ncrunchproject @@ -13,7 +13,9 @@ true true 60000 - - + + + AutoDetect + PostBuildEventDisabled \ No newline at end of file diff --git a/ServiceHelpers/ServiceUninstall/ServiceUninstall.ncrunchproject b/ServiceHelpers/ServiceUninstall/ServiceUninstall.ncrunchproject index 8641d3614..73e1ebbb9 100644 --- a/ServiceHelpers/ServiceUninstall/ServiceUninstall.ncrunchproject +++ b/ServiceHelpers/ServiceUninstall/ServiceUninstall.ncrunchproject @@ -13,7 +13,9 @@ true true 60000 - - + + + AutoDetect + PostBuildEventDisabled \ No newline at end of file