Browse Source

Added first debugger test

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@398 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
f4b2e8bfdd
  1. 34
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Configuration/AssemblyInfo.cs
  2. 46
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj
  3. 3
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj.user
  4. 106
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/DebuggerTests.cs
  5. 19
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ConsoleHelloWorld.cs
  6. 19
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DiagnosticsDebugHelloWorld.cs
  7. 19
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/SimpleProgram.cs
  8. 8
      src/SharpDevelop.WithTests.sln

34
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Configuration/AssemblyInfo.cs

@ -0,0 +1,34 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("2.0.0.1")]

46
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj

@ -0,0 +1,46 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>Debugger.Tests</RootNamespace>
<AssemblyName>Debugger.Tests</AssemblyName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A4C858C8-51B6-4265-A695-A20FCEBA1D19}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>..\..\..\..\..\..\AddIns\AddIns\Misc\Debugger\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
<Optimize>true</Optimize>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="nunit.framework, Version=2.2.2.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" />
<Reference Include="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</ItemGroup>
<ItemGroup>
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Src\DebuggerTests.cs" />
<EmbeddedResource Include="Src\TestPrograms\SimpleProgram.cs" />
<EmbeddedResource Include="Src\TestPrograms\ConsoleHelloWorld.cs" />
<EmbeddedResource Include="Src\TestPrograms\DiagnosticsDebugHelloWorld.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Src" />
<Folder Include="Configuration" />
<ProjectReference Include="..\..\Debugger.AddIn\Project\Debugger.AddIn.csproj">
<Project>{EC06F96A-AEEC-49D6-B03D-AB87C6EB674C}</Project>
<Name>Debugger.AddIn</Name>
</ProjectReference>
<ProjectReference Include="..\..\Debugger.Core\Project\Debugger.Core.csproj">
<Project>{1D18D788-F7EE-4585-A23B-34DC8EC63CB8}</Project>
<Name>Debugger.Core</Name>
</ProjectReference>
<Folder Include="Src\TestPrograms" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

3
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj.user

@ -0,0 +1,3 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
</Project>

106
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/DebuggerTests.cs

@ -0,0 +1,106 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using DebuggerLibrary;
using Microsoft.CSharp;
using NUnit.Framework;
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Threading;
namespace DebuggerLibrary.Tests
{
/// <summary>
/// This class contains methods that test the debugger
/// </summary>
[TestFixture]
public class DebuggerTests
{
string resourcePrefix = "Debugger.Tests.Src.TestPrograms.";
string tempPath = MakeTempDirectory();
Hashtable programs = new Hashtable();
NDebugger debugger = new NDebugger();
public DebuggerTests()
{
CompileTestPrograms();
}
public void CompileTestPrograms()
{
Assembly assembly = Assembly.GetExecutingAssembly();
foreach(string name in assembly.GetManifestResourceNames()) {
if (name.StartsWith(resourcePrefix)) {
string programName = name.Substring(resourcePrefix.Length, name.Length - resourcePrefix.Length - ".cs".Length);
Stream codeStream = assembly.GetManifestResourceStream(name);
string code = new StreamReader(codeStream).ReadToEnd();
string codeFilename = Path.Combine(tempPath, programName + ".cs");
string exeFilename = Path.Combine(tempPath, programName + ".exe");
StreamWriter file = new StreamWriter(codeFilename);
file.Write(code);
file.Close();
CompilerParameters compParams = new CompilerParameters();
compParams.GenerateExecutable = true;
compParams.GenerateInMemory = false;
compParams.TreatWarningsAsErrors = false;
compParams.IncludeDebugInformation = true;
compParams.ReferencedAssemblies.Add("System.dll");
compParams.OutputAssembly = exeFilename;
CSharpCodeProvider compiler = new CSharpCodeProvider();
CompilerResults result = compiler.CompileAssemblyFromFile(compParams, codeFilename);
if (result.Errors.Count > 0) {
throw new System.Exception("There was an error(s) during compilation of test program:\n" + result.Errors[0].ToString());
}
programs.Add(programName, exeFilename);
}
}
}
~DebuggerTests()
{
//Directory.Delete(tempPath, true);
}
static string MakeTempDirectory()
{
Random rand = new Random();
string path;
do {
path = Path.Combine(Path.GetTempPath(), "SharpDevelop");
path = Path.Combine(path, "DebuggerTests" + rand.Next(10000,99999));
} while (Directory.Exists(path));
Directory.CreateDirectory(path);
return path;
}
[Test]
public void RunSimpleProgram()
{
ManualResetEvent exitedEvent = new ManualResetEvent(false);
debugger.ProcessExited += delegate {
exitedEvent.Set();
};
debugger.Start((string)programs["SimpleProgram"], tempPath, "");
if (!exitedEvent.WaitOne(1000, false)) {
throw new System.Exception("Time out");
}
}
}
}

19
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ConsoleHelloWorld.cs

@ -0,0 +1,19 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
namespace DebuggerLibrary.Tests.TestPrograms
{
public class ConsoleHelloWorld
{
public static void Main()
{
Console.WriteLine("Hello world!");
}
}
}

19
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DiagnosticsDebugHelloWorld.cs

@ -0,0 +1,19 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
namespace DebuggerLibrary.Tests.TestPrograms
{
public class DiagnosticsDebugHelloWorld
{
public static void Main()
{
System.Diagnostics.Debug.WriteLine("Hello world!");
}
}
}

19
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/SimpleProgram.cs

@ -0,0 +1,19 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
namespace DebuggerLibrary.Tests.TestPrograms
{
public class SimpleProgram
{
public static void Main()
{
}
}
}

8
src/SharpDevelop.WithTests.sln

@ -1,5 +1,5 @@
Microsoft Visual Studio Solution File, Format Version 9.00 Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.0.0.352 # SharpDevelop 2.0.0.397
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AddIns", "AddIns", "{14A277EE-7DF1-4529-B639-7D1EF334C1C5}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AddIns", "AddIns", "{14A277EE-7DF1-4529-B639-7D1EF334C1C5}"
ProjectSection(SolutionItems) = postProject ProjectSection(SolutionItems) = postProject
EndProjectSection EndProjectSection
@ -36,6 +36,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Debugger", "Debugger", "{66
ProjectSection(SolutionItems) = postProject ProjectSection(SolutionItems) = postProject
EndProjectSection EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.Tests", "AddIns\Misc\Debugger\Debugger.Tests\Project\Debugger.Tests.csproj", "{A4C858C8-51B6-4265-A695-A20FCEBA1D19}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.AddIn", "AddIns\Misc\Debugger\Debugger.AddIn\Project\Debugger.AddIn.csproj", "{EC06F96A-AEEC-49D6-B03D-AB87C6EB674C}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.AddIn", "AddIns\Misc\Debugger\Debugger.AddIn\Project\Debugger.AddIn.csproj", "{EC06F96A-AEEC-49D6-B03D-AB87C6EB674C}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.Core", "AddIns\Misc\Debugger\Debugger.Core\Project\Debugger.Core.csproj", "{1D18D788-F7EE-4585-A23B-34DC8EC63CB8}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.Core", "AddIns\Misc\Debugger\Debugger.Core\Project\Debugger.Core.csproj", "{1D18D788-F7EE-4585-A23B-34DC8EC63CB8}"
@ -60,8 +62,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryTests", "Librarie
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Build.Tasks", "Libraries\ICSharpCode.Build.Tasks\Project\ICSharpCode.Build.Tasks.csproj", "{4139CCF6-FB49-4A9D-B2CF-331E9EA3198D}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Build.Tasks", "Libraries\ICSharpCode.Build.Tasks\Project\ICSharpCode.Build.Tasks.csproj", "{4139CCF6-FB49-4A9D-B2CF-331E9EA3198D}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nunit.framework.dll", "Tools\NUnit\src\NUnitFramework\framework\nunit.framework.dll.csproj", "{83DD7E12-A705-4DBA-9D71-09C8973D9382}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsUI", "Libraries\DockPanel_Src\WinFormsUI\WinFormsUI.csproj", "{D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsUI", "Libraries\DockPanel_Src\WinFormsUI\WinFormsUI.csproj", "{D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor", "Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj", "{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor", "Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj", "{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}"
@ -185,10 +185,10 @@ Global
{B08385CD-F0CC-488C-B4F4-EEB34B6D2688} = {6604365C-C702-4C10-9BA8-637F1E3D4D0D} {B08385CD-F0CC-488C-B4F4-EEB34B6D2688} = {6604365C-C702-4C10-9BA8-637F1E3D4D0D}
{1D18D788-F7EE-4585-A23B-34DC8EC63CB8} = {6604365C-C702-4C10-9BA8-637F1E3D4D0D} {1D18D788-F7EE-4585-A23B-34DC8EC63CB8} = {6604365C-C702-4C10-9BA8-637F1E3D4D0D}
{EC06F96A-AEEC-49D6-B03D-AB87C6EB674C} = {6604365C-C702-4C10-9BA8-637F1E3D4D0D} {EC06F96A-AEEC-49D6-B03D-AB87C6EB674C} = {6604365C-C702-4C10-9BA8-637F1E3D4D0D}
{A4C858C8-51B6-4265-A695-A20FCEBA1D19} = {6604365C-C702-4C10-9BA8-637F1E3D4D0D}
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195} = {9421EDF4-9769-4BE9-B5A6-C87DE221D73C} {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195} = {9421EDF4-9769-4BE9-B5A6-C87DE221D73C}
{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D} = {9421EDF4-9769-4BE9-B5A6-C87DE221D73C} {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D} = {9421EDF4-9769-4BE9-B5A6-C87DE221D73C}
{D3C782BA-178E-4235-A3BA-8C11DEBB6BEE} = {9421EDF4-9769-4BE9-B5A6-C87DE221D73C} {D3C782BA-178E-4235-A3BA-8C11DEBB6BEE} = {9421EDF4-9769-4BE9-B5A6-C87DE221D73C}
{83DD7E12-A705-4DBA-9D71-09C8973D9382} = {9421EDF4-9769-4BE9-B5A6-C87DE221D73C}
{4139CCF6-FB49-4A9D-B2CF-331E9EA3198D} = {9421EDF4-9769-4BE9-B5A6-C87DE221D73C} {4139CCF6-FB49-4A9D-B2CF-331E9EA3198D} = {9421EDF4-9769-4BE9-B5A6-C87DE221D73C}
{870115DD-960A-4406-A6B9-600BCDC36A03} = {9421EDF4-9769-4BE9-B5A6-C87DE221D73C} {870115DD-960A-4406-A6B9-600BCDC36A03} = {9421EDF4-9769-4BE9-B5A6-C87DE221D73C}
{1152B71B-3C05-4598-B20D-823B5D40559E} = {5A3EBEBA-0560-41C1-966B-23F7D03A5486} {1152B71B-3C05-4598-B20D-823B5D40559E} = {5A3EBEBA-0560-41C1-966B-23F7D03A5486}

Loading…
Cancel
Save