diff --git a/src/AddIns/Misc/CodeCoverage/CodeCoverage.sln b/src/AddIns/Misc/CodeCoverage/CodeCoverage.sln index c0781fb1ac..c301e3d780 100644 --- a/src/AddIns/Misc/CodeCoverage/CodeCoverage.sln +++ b/src/AddIns/Misc/CodeCoverage/CodeCoverage.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 -# SharpDevelop 3.0.0.2745 +# SharpDevelop 3.0.0.3280 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCoverage", "Project\CodeCoverage.csproj", "{08CE9972-283B-44F4-82FA-966F7DFA6B7A}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCoverage.Tests", "Test\CodeCoverage.Tests.csproj", "{A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}" @@ -36,18 +36,10 @@ Global {A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}.Release|Any CPU.Build.0 = Release|Any CPU {A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B1CE28A0-04E8-490D-8256-E0C4D52C93C8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B1CE28A0-04E8-490D-8256-E0C4D52C93C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B1CE28A0-04E8-490D-8256-E0C4D52C93C8}.Release|Any CPU.Build.0 = Release|Any CPU - {B1CE28A0-04E8-490D-8256-E0C4D52C93C8}.Release|Any CPU.ActiveCfg = Release|Any CPU {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Debug|Any CPU.Build.0 = Debug|Any CPU {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Any CPU.Build.0 = Release|Any CPU {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {83DD7E12-A705-4DBA-9D71-09C8973D9382}.Debug|Any CPU.Build.0 = Debug|Any CPU - {83DD7E12-A705-4DBA-9D71-09C8973D9382}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {83DD7E12-A705-4DBA-9D71-09C8973D9382}.Release|Any CPU.Build.0 = Release|Any CPU - {83DD7E12-A705-4DBA-9D71-09C8973D9382}.Release|Any CPU.ActiveCfg = Release|Any CPU {D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}.Debug|Any CPU.Build.0 = Debug|Any CPU {D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}.Release|Any CPU.Build.0 = Release|Any CPU @@ -64,10 +56,6 @@ Global {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.Build.0 = Release|Any CPU {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F6A02431-167E-4347-BC43-65532C31CDB7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F6A02431-167E-4347-BC43-65532C31CDB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F6A02431-167E-4347-BC43-65532C31CDB7}.Release|Any CPU.Build.0 = Release|Any CPU - {F6A02431-167E-4347-BC43-65532C31CDB7}.Release|Any CPU.ActiveCfg = Release|Any CPU {1F261725-6318-4434-A1B1-6C70CE4CD324}.Debug|Any CPU.Build.0 = Debug|Any CPU {1F261725-6318-4434-A1B1-6C70CE4CD324}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1F261725-6318-4434-A1B1-6C70CE4CD324}.Release|Any CPU.Build.0 = Release|Any CPU diff --git a/src/AddIns/Misc/CodeCoverage/Project/Src/RunTestWithCodeCoverageCommand.cs b/src/AddIns/Misc/CodeCoverage/Project/Src/RunTestWithCodeCoverageCommand.cs index 9f36c674b9..d3e0d87b1f 100644 --- a/src/AddIns/Misc/CodeCoverage/Project/Src/RunTestWithCodeCoverageCommand.cs +++ b/src/AddIns/Misc/CodeCoverage/Project/Src/RunTestWithCodeCoverageCommand.cs @@ -94,7 +94,7 @@ namespace ICSharpCode.CodeCoverage } runner.PartCoverFileName = GetPartCoverFileName(); - runner.Target = UnitTestApplicationStartHelper.UnitTestConsoleApplication; + runner.Target = helper.UnitTestApplication; runner.TargetArguments = helper.GetArguments(); runner.TargetWorkingDirectory = Path.GetDirectoryName(helper.Assemblies[0]); runner.Output = Path.Combine(partCoverOutputDirectory, "Coverage.Xml"); diff --git a/src/AddIns/Misc/UnitTesting/Src/RunTestCommands.cs b/src/AddIns/Misc/UnitTesting/Src/RunTestCommands.cs index 2b1c0262a7..89e145afe8 100644 --- a/src/AddIns/Misc/UnitTesting/Src/RunTestCommands.cs +++ b/src/AddIns/Misc/UnitTesting/Src/RunTestCommands.cs @@ -437,7 +437,7 @@ namespace ICSharpCode.UnitTesting protected override void RunTests(UnitTestApplicationStartHelper helper) { TestRunnerCategory.AppendLine(helper.GetCommandLine()); - runner.Start(UnitTestApplicationStartHelper.UnitTestConsoleApplication, helper.GetArguments()); + runner.Start(helper.UnitTestApplication, helper.GetArguments()); } protected override void OnStop() @@ -488,7 +488,7 @@ namespace ICSharpCode.UnitTesting try { TestRunnerCategory.AppendLine(helper.GetCommandLine()); - ProcessStartInfo startInfo = new ProcessStartInfo(UnitTestApplicationStartHelper.UnitTestConsoleApplication); + ProcessStartInfo startInfo = new ProcessStartInfo(helper.UnitTestApplication); startInfo.Arguments = helper.GetArguments(); startInfo.WorkingDirectory = UnitTestApplicationStartHelper.UnitTestApplicationDirectory; DebuggerService.DebugStopped += DebuggerFinished; diff --git a/src/AddIns/Misc/UnitTesting/Src/UnitTestApplicationStartHelper.cs b/src/AddIns/Misc/UnitTesting/Src/UnitTestApplicationStartHelper.cs index edf6fefd0f..65250b7a3e 100644 --- a/src/AddIns/Misc/UnitTesting/Src/UnitTestApplicationStartHelper.cs +++ b/src/AddIns/Misc/UnitTesting/Src/UnitTestApplicationStartHelper.cs @@ -31,16 +31,21 @@ namespace ICSharpCode.UnitTesting return Path.Combine(FileUtility.ApplicationRootPath, @"bin\Tools\NUnit"); } } - + /// - /// returns full/path/to/Tools/NUnit/nunit-console.exe + /// returns full/path/to/Tools/NUnit/nunit-console.exe or nunit-console-x86.exe if the + /// project platform target is x86. /// - public static string UnitTestConsoleApplication { + public string UnitTestApplication { get { - return Path.Combine(UnitTestApplicationDirectory, "nunit-console.exe"); + string exe = "nunit-console.exe"; + if (IsPlatformTarget32Bit(project)) { + exe = "nunit-console-x86.exe"; + } + return Path.Combine(UnitTestApplicationDirectory, exe); } } - + public readonly List Assemblies = new List(); /// @@ -129,12 +134,12 @@ namespace ICSharpCode.UnitTesting /// /// Gets the full command line to run the unit test application. - /// This is the combination of the UnitTestConsoleApplication and + /// This is the combination of the UnitTestApplication and /// the command line arguments. /// public string GetCommandLine() { - return String.Concat("\"", UnitTestConsoleApplication, "\" ", GetArguments()); + return String.Concat("\"", UnitTestApplication, "\" ", GetArguments()); } /// @@ -189,5 +194,18 @@ namespace ICSharpCode.UnitTesting } return b.ToString(); } + + /// + /// Checks that the project's PlatformTarget is x86 for the active configuration. + /// + bool IsPlatformTarget32Bit(IProject project) + { + MSBuildBasedProject msbuildProject = project as MSBuildBasedProject; + if (msbuildProject != null) { + string platformTarget = msbuildProject.GetProperty(project.ActiveConfiguration, project.ActivePlatform, "PlatformTarget"); + return String.Compare(platformTarget, "x86", true) == 0; + } + return false; + } } } diff --git a/src/AddIns/Misc/UnitTesting/Test/NUnitConsoleExeSelectedTestFixture.cs b/src/AddIns/Misc/UnitTesting/Test/NUnitConsoleExeSelectedTestFixture.cs new file mode 100644 index 0000000000..37aacc7c8a --- /dev/null +++ b/src/AddIns/Misc/UnitTesting/Test/NUnitConsoleExeSelectedTestFixture.cs @@ -0,0 +1,72 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Project; +using NUnit.Framework; +using ICSharpCode.UnitTesting; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests +{ + /// + /// If the project explicitly targets 32 bit (x86) architecture then nunit-console-x86.exe should be + /// used. Otherwise the normal nunit-console.exe is used. + /// + [TestFixture] + public class NUnitConsoleExeSelectedTestFixture + { + string oldRootPath; + + [TestFixtureSetUpAttribute] + public void SetUpFixture() + { + oldRootPath = FileUtility.ApplicationRootPath; + FileUtility.ApplicationRootPath = @"D:\SharpDevelop"; + } + + [TestFixtureTearDown] + public void TearDownFixture() + { + FileUtility.ApplicationRootPath = oldRootPath; + } + + [Test] + public void NothingSpecified() + { + MockCSharpProject project = new MockCSharpProject(); + UnitTestApplicationStartHelper helper = new UnitTestApplicationStartHelper(); + helper.Initialize(project, null); + Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console.exe", helper.UnitTestApplication); + } + + [Test] + public void NUnitConsole32BitUsedWhenTargetCpuIs32Bit() + { + MockCSharpProject project = new MockCSharpProject(); + project.ActiveConfiguration = "Debug"; + project.ActivePlatform = "AnyCPU"; + project.SetProperty("PlatformTarget", "x86"); + + UnitTestApplicationStartHelper helper = new UnitTestApplicationStartHelper(); + helper.Initialize(project, null); + Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console-x86.exe", helper.UnitTestApplication); + } + + [Test] + public void NotMSBuildBasedProject() + { + MissingProject project = new MissingProject(@"C:\Projects\Test.proj", "Test"); + UnitTestApplicationStartHelper helper = new UnitTestApplicationStartHelper(); + helper.Initialize(project, null); + + Assert.AreEqual(project.GetType().BaseType, typeof(AbstractProject), "MissingProject should be derived from AbstractProject."); + Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console.exe", helper.UnitTestApplication); + } + } +} diff --git a/src/AddIns/Misc/UnitTesting/Test/UnitTesting.Tests.csproj b/src/AddIns/Misc/UnitTesting/Test/UnitTesting.Tests.csproj index 243788be56..4ad35683e7 100644 --- a/src/AddIns/Misc/UnitTesting/Test/UnitTesting.Tests.csproj +++ b/src/AddIns/Misc/UnitTesting/Test/UnitTesting.Tests.csproj @@ -59,6 +59,7 @@ + diff --git a/src/Setup/Files.wxs b/src/Setup/Files.wxs index 31b0b0e68a..b89841868f 100644 --- a/src/Setup/Files.wxs +++ b/src/Setup/Files.wxs @@ -428,6 +428,10 @@ + + + + diff --git a/src/Setup/Setup.wxs b/src/Setup/Setup.wxs index 16cd4655c8..18735c0d4d 100644 --- a/src/Setup/Setup.wxs +++ b/src/Setup/Setup.wxs @@ -270,6 +270,7 @@ + diff --git a/src/Tools/Tools.build b/src/Tools/Tools.build index 365b77f796..8fb7021de3 100644 --- a/src/Tools/Tools.build +++ b/src/Tools/Tools.build @@ -13,7 +13,7 @@ - + @@ -34,7 +34,7 @@ - +