Browse Source

Added support for nunit-console-x86.exe so 32-bit unit tests can be run on a 64-bit system.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3475 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 18 years ago
parent
commit
0474a93678
  1. 14
      src/AddIns/Misc/CodeCoverage/CodeCoverage.sln
  2. 2
      src/AddIns/Misc/CodeCoverage/Project/Src/RunTestWithCodeCoverageCommand.cs
  3. 4
      src/AddIns/Misc/UnitTesting/Src/RunTestCommands.cs
  4. 32
      src/AddIns/Misc/UnitTesting/Src/UnitTestApplicationStartHelper.cs
  5. 72
      src/AddIns/Misc/UnitTesting/Test/NUnitConsoleExeSelectedTestFixture.cs
  6. 1
      src/AddIns/Misc/UnitTesting/Test/UnitTesting.Tests.csproj
  7. 4
      src/Setup/Files.wxs
  8. 1
      src/Setup/Setup.wxs
  9. 4
      src/Tools/Tools.build

14
src/AddIns/Misc/CodeCoverage/CodeCoverage.sln

@ -1,7 +1,7 @@ @@ -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 @@ -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 @@ -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

2
src/AddIns/Misc/CodeCoverage/Project/Src/RunTestWithCodeCoverageCommand.cs

@ -94,7 +94,7 @@ namespace ICSharpCode.CodeCoverage @@ -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");

4
src/AddIns/Misc/UnitTesting/Src/RunTestCommands.cs

@ -437,7 +437,7 @@ namespace ICSharpCode.UnitTesting @@ -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 @@ -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;

32
src/AddIns/Misc/UnitTesting/Src/UnitTestApplicationStartHelper.cs

@ -31,16 +31,21 @@ namespace ICSharpCode.UnitTesting @@ -31,16 +31,21 @@ namespace ICSharpCode.UnitTesting
return Path.Combine(FileUtility.ApplicationRootPath, @"bin\Tools\NUnit");
}
}
/// <summary>
/// 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.
/// </summary>
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<string> Assemblies = new List<string>();
/// <summary>
@ -129,12 +134,12 @@ namespace ICSharpCode.UnitTesting @@ -129,12 +134,12 @@ namespace ICSharpCode.UnitTesting
/// <summary>
/// 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.
/// </summary>
public string GetCommandLine()
{
return String.Concat("\"", UnitTestConsoleApplication, "\" ", GetArguments());
return String.Concat("\"", UnitTestApplication, "\" ", GetArguments());
}
/// <summary>
@ -189,5 +194,18 @@ namespace ICSharpCode.UnitTesting @@ -189,5 +194,18 @@ namespace ICSharpCode.UnitTesting
}
return b.ToString();
}
/// <summary>
/// Checks that the project's PlatformTarget is x86 for the active configuration.
/// </summary>
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;
}
}
}

72
src/AddIns/Misc/UnitTesting/Test/NUnitConsoleExeSelectedTestFixture.cs

@ -0,0 +1,72 @@ @@ -0,0 +1,72 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Project;
using NUnit.Framework;
using ICSharpCode.UnitTesting;
using UnitTesting.Tests.Utils;
namespace UnitTesting.Tests
{
/// <summary>
/// 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.
/// </summary>
[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);
}
}
}

1
src/AddIns/Misc/UnitTesting/Test/UnitTesting.Tests.csproj

@ -59,6 +59,7 @@ @@ -59,6 +59,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="NUnitConsoleExeSelectedTestFixture.cs" />
<Compile Include="Project\AbstractBaseClassWithTestMethodsTestFixture.cs" />
<Compile Include="Project\BaseTestMethodTestFixture.cs" />
<Compile Include="TestableConditionTests.cs" />

4
src/Setup/Files.wxs

@ -428,6 +428,10 @@ @@ -428,6 +428,10 @@
<Component Guid="D67E8EC9-2D98-4889-856F-78FD2BE35947" Id="NUnitCoreInterfacesDll" DiskId="1">
<File Id="nunit.core.interfaces.dll" KeyPath="yes" Name="nunit.core.interfaces.dll" Assembly=".net" AssemblyApplication="nunit.core.interfaces.dll" AssemblyManifest="nunit.core.interfaces.dll" Source="..\..\bin\Tools\NUnit\nunit.core.interfaces.dll" />
</Component>
<Component Guid="C996D268-4471-4CBF-9015-43357863360A" Id="NUnitConsoleX86Files" DiskId="1">
<File Source="..\..\bin\Tools\NUnit\nunit-console-x86.exe" Name="nunit-console-x86.exe" Id="nunit_console_x86.exe" Assembly=".net" KeyPath="yes" AssemblyApplication="nunit_console_x86.exe" AssemblyManifest="nunit_console_x86.exe" />
<File Source="..\..\bin\Tools\NUnit\nunit-console-x86.exe.config" Name="nunit-console-x86.exe.config" Id="nunit_console_x86.exe.config" />
</Component>
</Directory>
<Directory Id="PartCover" Name="PartCover">
<Component Guid="CD9AB556-51BD-4DB2-9AC5-C047022991DD" Id="InteropPartCoverDll" DiskId="1">

1
src/Setup/Setup.wxs

@ -270,6 +270,7 @@ @@ -270,6 +270,7 @@
<ComponentRef Id="NUnitUiKitDll"/>
<ComponentRef Id="NUnitUtilDll"/>
<ComponentRef Id="NUnitConsoleFiles"/>
<ComponentRef Id="NUnitConsoleX86Files"/>
<ComponentRef Id="NUnitCoreDll"/>
<ComponentRef Id="NUnitFrameworkDll"/>
<ComponentRef Id="NunitConsoleRunnerDll"/>

4
src/Tools/Tools.build

@ -13,7 +13,7 @@ @@ -13,7 +13,7 @@
<WixDocFiles Include="wix\doc\*"/>
<WixLibFiles Include="wix\lib\*"/>
<NUnitFiles Include="NUnit\*.dll;NUnit\*.exe"/>
<NUnitConfigFile Include="NUnit\nunit-console.exe.config"/>
<NUnitConfigFiles Include="NUnit\nunit-console.exe.config;NUnit\nunit-console-x86.exe.config"/>
<HelpToolFiles Include="Help\*"/>
<PartCoverFiles Include="PartCover\*"/>
<PartCoverXsltFiles Include="PartCover\xslt\*"/>
@ -34,7 +34,7 @@ @@ -34,7 +34,7 @@
<Copy SourceFiles="@(WixBitmapFiles)" DestinationFolder="..\..\bin\Tools\Wix\Bitmaps" SkipUnchangedFiles="true"/>
<Copy SourceFiles="@(WixLibFiles)" DestinationFolder="..\..\bin\Tools\Wix\lib" SkipUnchangedFiles="true"/>
<Copy SourceFiles="@(NUnitFiles)" DestinationFolder="..\..\bin\Tools\NUnit" SkipUnchangedFiles="true"/>
<Copy SourceFiles="@(NUnitConfigFile)" DestinationFolder="..\..\bin\Tools\NUnit" SkipUnchangedFiles="true"/>
<Copy SourceFiles="@(NUnitConfigFiles)" DestinationFolder="..\..\bin\Tools\NUnit" SkipUnchangedFiles="true"/>
<Copy SourceFiles="@(ToolFiles)" DestinationFolder="..\..\bin\Tools" SkipUnchangedFiles="true"/>
<Copy SourceFiles="@(PartCoverFiles)" DestinationFolder="..\..\bin\Tools\PartCover" SkipUnchangedFiles="true"/>
<Copy SourceFiles="@(PartCoverXsltFiles)" DestinationFolder="..\..\bin\Tools\PartCover\Xslt" SkipUnchangedFiles="true"/>

Loading…
Cancel
Save