Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@398 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
8 changed files with 250 additions and 4 deletions
@ -0,0 +1,34 @@
@@ -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")] |
||||
|
@ -0,0 +1,46 @@
@@ -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> |
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " /> |
||||
</Project> |
@ -0,0 +1,106 @@
@@ -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"); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,19 @@
@@ -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!"); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,19 @@
@@ -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!"); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,19 @@
@@ -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() |
||||
{ |
||||
|
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue