Browse Source

Support running unit tests in .NET 4.0 projects.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/dotnet4@4278 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 17 years ago
parent
commit
aa044b3834
  1. 36
      src/AddIns/Misc/UnitTesting/Src/UnitTestApplicationStartHelper.cs
  2. 26
      src/Automated.proj
  3. 3
      src/Main/Core/Test/ICSharpCode.Core.Tests.csproj
  4. 2
      src/Setup/SharpDevelop.Setup.wixproj.user
  5. 2
      src/Tools/NUnit/buildnunitconsole.bat
  6. BIN
      src/Tools/NUnit/nunit-console-dotnet4-x86.exe
  7. 91
      src/Tools/NUnit/nunit-console-dotnet4-x86.exe.config
  8. BIN
      src/Tools/NUnit/nunit-console-dotnet4.exe
  9. 91
      src/Tools/NUnit/nunit-console-dotnet4.exe.config
  10. 11
      src/Tools/Tools.build
  11. 7
      src/Tools/UpdateAssemblyInfo/Main.cs
  12. 2
      src/Tools/UpdateAssemblyInfo/UpdateAssemblyInfo.csproj
  13. 21
      src/Tools/UpdateAssemblyInfo/app.manifest
  14. BIN
      src/Tools/UpdateAssemblyInfo/bin/Debug/UpdateAssemblyInfo.exe

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

@ -31,17 +31,21 @@ namespace ICSharpCode.UnitTesting @@ -31,17 +31,21 @@ namespace ICSharpCode.UnitTesting
return Path.Combine(FileUtility.ApplicationRootPath, @"bin\Tools\NUnit");
}
}
/// <summary>
/// returns full/path/to/Tools/NUnit/nunit-console.exe or nunit-console-x86.exe if the
/// project platform target is x86.
/// returns full/path/to/Tools/NUnit/nunit-console.exe (or whichever nunit-console exe is right
/// for the project - there are different .exes for .NET 4.0 and for x86-only projects.
/// </summary>
public string UnitTestApplication {
get {
string exe = "nunit-console.exe";
string exe = "nunit-console";
if (IsDotNet40Project(project)) {
exe += "-dotnet4";
}
if (IsPlatformTarget32Bit(project)) {
exe = "nunit-console-x86.exe";
exe += "-x86";
}
exe += ".exe";
return Path.Combine(UnitTestApplicationDirectory, exe);
}
}
@ -66,12 +70,12 @@ namespace ICSharpCode.UnitTesting @@ -66,12 +70,12 @@ namespace ICSharpCode.UnitTesting
/// <summary>
/// Use /labels directive.
/// </summary>
public bool Labels = false;
public bool Labels = false;
/// <summary>
/// Use /nodots directive.
/// </summary>
public bool NoDots = false;
public bool NoDots = false;
/// <summary>
/// File to write xml output to. Default = null.
@ -94,7 +98,7 @@ namespace ICSharpCode.UnitTesting @@ -94,7 +98,7 @@ namespace ICSharpCode.UnitTesting
public string Results;
/// <summary>
/// The namespace that tests need to be a part of if they are to
/// The namespace that tests need to be a part of if they are to
/// be run.
/// </summary>
public string NamespaceFilter;
@ -131,7 +135,7 @@ namespace ICSharpCode.UnitTesting @@ -131,7 +135,7 @@ namespace ICSharpCode.UnitTesting
return project;
}
}
/// <summary>
/// Gets the full command line to run the unit test application.
/// This is the combination of the UnitTestApplication and
@ -161,9 +165,9 @@ namespace ICSharpCode.UnitTesting @@ -161,9 +165,9 @@ namespace ICSharpCode.UnitTesting
b.Append(" /nothread");
if (NoLogo)
b.Append(" /nologo");
if (Labels)
if (Labels)
b.Append(" /labels");
if (NoDots)
if (NoDots)
b.Append(" /nodots");
if (XmlOutputFile != null) {
b.Append(" /xml=\"");
@ -207,5 +211,15 @@ namespace ICSharpCode.UnitTesting @@ -207,5 +211,15 @@ namespace ICSharpCode.UnitTesting
}
return false;
}
bool IsDotNet40Project(IProject project)
{
MSBuildBasedProject msbuildProject = project as MSBuildBasedProject;
if (msbuildProject != null) {
string targetFrameworkVersion = msbuildProject.GetEvaluatedProperty("TargetFrameworkVersion");
return String.Compare(targetFrameworkVersion, "v4.0", true) == 0;
}
return false;
}
}
}

26
src/Automated.proj

@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
(but this works using the command line) -->
<!-- B) The Wix task assembly is locked if we do not use a separate MSBuild process -->
<!-- C) We need to use MSBuild 3.5, but the build server uses MSBuild 2.0 -->
<MSBuildExecutable>&quot;$(MSBuildBinPath)\..\v3.5\msbuild.exe&quot;</MSBuildExecutable>
<MSBuildExecutable>&quot;$(MSBuildBinPath)\..\v4.0.20506\msbuild.exe&quot;</MSBuildExecutable>
<BuildProperties>/p:Configuration=Release</BuildProperties>
<BuildProperties>$(BuildProperties) &quot;/p:SharpDevelopBinPath=$(SharpDevelopBin)&quot;</BuildProperties>
<BuildProperties>$(BuildProperties) &quot;/p:BooBinPath=$(SharpDevelopSrc)\AddIns\BackendBindings\Boo\RequiredLibraries&quot;</BuildProperties>
@ -67,14 +67,14 @@ @@ -67,14 +67,14 @@
<Copy SourceFiles="$(ProjectDir)\REVISION"
DestinationFolder="$(ArtefactsOutputDir)"/>
<Exec WorkingDirectory="$(SharpDevelopSrc)"
<Exec WorkingDirectory="$(ProjectDir)"
Command="$(MSBuildExecutable) SharpDevelop.sln $(BuildProperties)"/>
<Exec WorkingDirectory="$(ProfilerSrc)"
Command="$(MSBuildExecutable) AutomatedBuild.proj $(BuildProperties)"/>
<!--<Exec WorkingDirectory="$(ProfilerSrc)"
Command="$(MSBuildExecutable) AutomatedBuild.proj $(BuildProperties)"/>-->
</Target>
<Target Name="buildunittests">
<Exec WorkingDirectory="$(SharpDevelopSrc)"
<Exec WorkingDirectory="$(ProjectDir)"
Command="$(MSBuildExecutable) SharpDevelop.Tests.sln $(BuildProperties)"/>
</Target>
@ -92,20 +92,20 @@ @@ -92,20 +92,20 @@
<!-- Yes, apparently we really need two identical clean tasks. MSBuild won't run the same task twice. -->
<Target Name="clean1">
<Exec WorkingDirectory="$(SharpDevelopSrc)"
<Exec WorkingDirectory="$(ProjectDir)"
Command="$(MSBuildExecutable) SharpDevelop.sln /t:Clean $(BuildProperties)"/>
<Exec WorkingDirectory="$(SharpDevelopSrc)"
<Exec WorkingDirectory="$(ProjectDir)"
Command="$(MSBuildExecutable) SharpDevelop.Tests.sln /t:Clean $(BuildProperties)"/>
<Exec WorkingDirectory="$(ProfilerSrc)"
Command="$(MSBuildExecutable) AutomatedBuild.proj /t:Clean $(BuildProperties)"/>
<!--<Exec WorkingDirectory="$(ProfilerSrc)"
Command="$(MSBuildExecutable) AutomatedBuild.proj /t:Clean $(BuildProperties)"/>-->
</Target>
<Target Name="clean2">
<Exec WorkingDirectory="$(SharpDevelopSrc)"
<Exec WorkingDirectory="$(ProjectDir)"
Command="$(MSBuildExecutable) SharpDevelop.sln /t:Clean $(BuildProperties)"/>
<Exec WorkingDirectory="$(SharpDevelopSrc)"
<Exec WorkingDirectory="$(ProjectDir)"
Command="$(MSBuildExecutable) SharpDevelop.Tests.sln /t:Clean $(BuildProperties)"/>
<Exec WorkingDirectory="$(ProfilerSrc)"
Command="$(MSBuildExecutable) AutomatedBuild.proj /t:Clean $(BuildProperties)"/>
<!--<Exec WorkingDirectory="$(ProfilerSrc)"
Command="$(MSBuildExecutable) AutomatedBuild.proj /t:Clean $(BuildProperties)"/>-->
</Target>
<Target Name="createsetup">

3
src/Main/Core/Test/ICSharpCode.Core.Tests.csproj

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@ -21,6 +21,7 @@ @@ -21,6 +21,7 @@
<RegisterForComInterop>False</RegisterForComInterop>
<PlatformTarget>AnyCPU</PlatformTarget>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>

2
src/Setup/SharpDevelop.Setup.wixproj.user

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SetupProductBuildVersion>1</SetupProductBuildVersion>
<SetupProductBuildVersion>4260</SetupProductBuildVersion>
<DefineConstants>PRODUCTBUILDVERSION=$(SetupProductBuildVersion)</DefineConstants>
</PropertyGroup>
</Project>

2
src/Tools/NUnit/buildnunitconsole.bat

@ -2,6 +2,8 @@ @@ -2,6 +2,8 @@
copy nunit-console.exe nunit-console-x86.exe
"%programfiles%\Microsoft.net\sdk\v2.0\bin\corflags" /32bit+ nunit-console-x86.exe
@IF %ERRORLEVEL% NEQ 0 GOTO err
copy nunit-console.exe nunit-console-dotnet4.exe
copy nunit-console-x86.exe nunit-console-dotnet4-x86.exe
@exit /B 0
:err
@PAUSE

BIN
src/Tools/NUnit/nunit-console-dotnet4-x86.exe

Binary file not shown.

91
src/Tools/NUnit/nunit-console-dotnet4-x86.exe.config

@ -0,0 +1,91 @@ @@ -0,0 +1,91 @@
<?xml version="1.0"?>
<configuration>
<startup>
<requiredRuntime version="v4.0.20506" />
</startup>
<!--
Application settings for NUnit-console.exe. Do NOT put settings
for use by your tests here.
-->
<appSettings>
<!--
Specify the location to be used by .NET for the cache
-->
<add key="shadowfiles.path" value="%temp%\nunit20\ShadowCopyCache" />
</appSettings>
<!-- Set the level for tracing NUnit itself -->
<!-- 0=Off 1=Error 2=Warning 3=Info 4=Debug -->
<system.diagnostics>
<switches>
<add name="NTrace" value="0" />
</switches>
</system.diagnostics>
<runtime>
<!-- We need this so test exceptions don't crash NUnit -->
<legacyUnhandledExceptionPolicy enabled="1" />
<!-- Look for addins in the addins directory for now -->
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="lib;addins"/>
</assemblyBinding>
<!--
The following <assemblyBinding> section allows running nunit under
.NET 1.0 by redirecting assemblies. The appliesTo attribute
causes the section to be ignored except under .NET 1.0
on a machine with only the .NET version 1.0 runtime installed.
If application and its tests were built for .NET 1.1 you will
also need to redirect system assemblies in the test config file,
which controls loading of the tests.
-->
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"
appliesTo="v1.0.3705">
<dependentAssembly>
<assemblyIdentity name="System"
publicKeyToken="b77a5c561934e089"
culture="neutral"/>
<bindingRedirect oldVersion="1.0.5000.0"
newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Data"
publicKeyToken="b77a5c561934e089"
culture="neutral"/>
<bindingRedirect oldVersion="1.0.5000.0"
newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Drawing"
publicKeyToken="b03f5f7f11d50a3a"
culture="neutral"/>
<bindingRedirect oldVersion="1.0.5000.0"
newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Windows.Forms"
publicKeyToken="b77a5c561934e089"
culture="neutral"/>
<bindingRedirect oldVersion="1.0.5000.0"
newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Xml"
publicKeyToken="b77a5c561934e089"
culture="neutral"/>
<bindingRedirect oldVersion="1.0.5000.0"
newVersion="1.0.3300.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

BIN
src/Tools/NUnit/nunit-console-dotnet4.exe

Binary file not shown.

91
src/Tools/NUnit/nunit-console-dotnet4.exe.config

@ -0,0 +1,91 @@ @@ -0,0 +1,91 @@
<?xml version="1.0"?>
<configuration>
<startup>
<requiredRuntime version="v4.0.20506" />
</startup>
<!--
Application settings for NUnit-console.exe. Do NOT put settings
for use by your tests here.
-->
<appSettings>
<!--
Specify the location to be used by .NET for the cache
-->
<add key="shadowfiles.path" value="%temp%\nunit20\ShadowCopyCache" />
</appSettings>
<!-- Set the level for tracing NUnit itself -->
<!-- 0=Off 1=Error 2=Warning 3=Info 4=Debug -->
<system.diagnostics>
<switches>
<add name="NTrace" value="0" />
</switches>
</system.diagnostics>
<runtime>
<!-- We need this so test exceptions don't crash NUnit -->
<legacyUnhandledExceptionPolicy enabled="1" />
<!-- Look for addins in the addins directory for now -->
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="lib;addins"/>
</assemblyBinding>
<!--
The following <assemblyBinding> section allows running nunit under
.NET 1.0 by redirecting assemblies. The appliesTo attribute
causes the section to be ignored except under .NET 1.0
on a machine with only the .NET version 1.0 runtime installed.
If application and its tests were built for .NET 1.1 you will
also need to redirect system assemblies in the test config file,
which controls loading of the tests.
-->
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"
appliesTo="v1.0.3705">
<dependentAssembly>
<assemblyIdentity name="System"
publicKeyToken="b77a5c561934e089"
culture="neutral"/>
<bindingRedirect oldVersion="1.0.5000.0"
newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Data"
publicKeyToken="b77a5c561934e089"
culture="neutral"/>
<bindingRedirect oldVersion="1.0.5000.0"
newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Drawing"
publicKeyToken="b03f5f7f11d50a3a"
culture="neutral"/>
<bindingRedirect oldVersion="1.0.5000.0"
newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Windows.Forms"
publicKeyToken="b77a5c561934e089"
culture="neutral"/>
<bindingRedirect oldVersion="1.0.5000.0"
newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Xml"
publicKeyToken="b77a5c561934e089"
culture="neutral"/>
<bindingRedirect oldVersion="1.0.5000.0"
newVersion="1.0.3300.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

11
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"/>
<NUnitConfigFiles Include="NUnit\nunit-console.exe.config;NUnit\nunit-console-x86.exe.config"/>
<NUnitConfigFiles Include="NUnit\*.config"/>
<NUnitLibFiles Include="NUnit\lib\*.dll"/>
<HelpToolFiles Include="Help\*"/>
<PartCoverFiles Include="PartCover\*"/>
@ -59,15 +59,8 @@ @@ -59,15 +59,8 @@
<Target Name="Rebuild" DependsOnTargets="Build"/>
<ItemGroup>
<PrepareReleaseProject Include="SVNChangeLogToXml\SVNChangeLogToXml.csproj" />
</ItemGroup>
<Target Name="PrepareRelease">
<MSBuild Projects="@(PrepareReleaseProject)" Targets="Build"/>
<Exec Command="SVNChangelogToXml.exe --REVISION --START 3800" WorkingDirectory = "SVNChangeLogToXml\bin\Release" Timeout = "60000" IgnoreExitCode = "false"/>
<RemoveDir Directories="SVNChangeLogToXml\bin" />
<RemoveDir Directories="SVNChangeLogToXml\obj" />
<Exec WorkingDirectory="UpdateAssemblyInfo\bin\Debug" Command="UpdateAssemblyInfo.exe --REVISION" Timeout = "60000" IgnoreExitCode = "false"/>
</Target>
<ItemGroup>

7
src/Tools/UpdateAssemblyInfo/Main.cs

@ -60,6 +60,13 @@ namespace UpdateAssemblyInfo @@ -60,6 +60,13 @@ namespace UpdateAssemblyInfo
string versionNumber = GetMajorVersion() + "." + revisionNumber;
UpdateStartup();
UpdateRedirectionConfig(versionNumber);
foreach (string arg in args) {
if (arg == "--REVISION") {
using (StreamWriter writer = new StreamWriter("REVISION")) {
writer.Write(revisionNumber);
}
}
}
return 0;
}
} catch (Exception ex) {

2
src/Tools/UpdateAssemblyInfo/UpdateAssemblyInfo.csproj

@ -20,7 +20,6 @@ @@ -20,7 +20,6 @@
<DebugSymbols>false</DebugSymbols>
<NoWarn>1607</NoWarn>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<ApplicationManifest>app.manifest</ApplicationManifest>
<SourceAnalysisOverrideSettingsFile>C:\Users\Daniel\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@ -44,7 +43,6 @@ @@ -44,7 +43,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Main.cs" />
<None Include="app.manifest" />
<None Include="Readme.txt" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />

21
src/Tools/UpdateAssemblyInfo/app.manifest

@ -1,21 +0,0 @@ @@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!--
The presence of the "requestedExecutionLevel" node will disable
file and registry virtualization on Vista.
Use the "level" attribute to specify the User Account Control level:
asInvoker = Never prompt for elevation
requireAdministrator = Always prompt for elevation
highestAvailable = Prompt for elevation when started by administrator,
but do not prompt for administrator password when started by
standard user.
-->
<requestedExecutionLevel level="asInvoker"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

BIN
src/Tools/UpdateAssemblyInfo/bin/Debug/UpdateAssemblyInfo.exe

Binary file not shown.
Loading…
Cancel
Save