diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Configuration/AssemblyInfo.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Configuration/AssemblyInfo.cs new file mode 100644 index 0000000000..4daf881581 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Configuration/AssemblyInfo.cs @@ -0,0 +1,34 @@ +// +// 2002-2005 AlphaSierraPapa +// GNU General Public License +// +// $Revision$ +// + +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")] + diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj new file mode 100644 index 0000000000..2fb6d3e852 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj @@ -0,0 +1,46 @@ + + + Library + Debugger.Tests + Debugger.Tests + Debug + AnyCPU + {A4C858C8-51B6-4265-A695-A20FCEBA1D19} + + + ..\..\..\..\..\..\AddIns\AddIns\Misc\Debugger\ + DEBUG;TRACE + + + bin\Release\ + true + TRACE + + + + + + + + + + + + + + + + + + + {EC06F96A-AEEC-49D6-B03D-AB87C6EB674C} + Debugger.AddIn + + + {1D18D788-F7EE-4585-A23B-34DC8EC63CB8} + Debugger.Core + + + + + \ No newline at end of file diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj.user b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj.user new file mode 100644 index 0000000000..c439b83dc4 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj.user @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/DebuggerTests.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/DebuggerTests.cs new file mode 100644 index 0000000000..fca4d4949b --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/DebuggerTests.cs @@ -0,0 +1,106 @@ +// +// 2002-2005 AlphaSierraPapa +// GNU General Public License +// +// $Revision$ +// + +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 +{ + /// + /// This class contains methods that test the debugger + /// + [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"); + } + } + } +} diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ConsoleHelloWorld.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ConsoleHelloWorld.cs new file mode 100644 index 0000000000..73d8ae9d78 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ConsoleHelloWorld.cs @@ -0,0 +1,19 @@ +// +// 2002-2005 AlphaSierraPapa +// GNU General Public License +// +// $Revision$ +// + +using System; + +namespace DebuggerLibrary.Tests.TestPrograms +{ + public class ConsoleHelloWorld + { + public static void Main() + { + Console.WriteLine("Hello world!"); + } + } +} diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DiagnosticsDebugHelloWorld.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DiagnosticsDebugHelloWorld.cs new file mode 100644 index 0000000000..8fadb169d4 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/DiagnosticsDebugHelloWorld.cs @@ -0,0 +1,19 @@ +// +// 2002-2005 AlphaSierraPapa +// GNU General Public License +// +// $Revision$ +// + +using System; + +namespace DebuggerLibrary.Tests.TestPrograms +{ + public class DiagnosticsDebugHelloWorld + { + public static void Main() + { + System.Diagnostics.Debug.WriteLine("Hello world!"); + } + } +} diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/SimpleProgram.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/SimpleProgram.cs new file mode 100644 index 0000000000..4501e3a800 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/SimpleProgram.cs @@ -0,0 +1,19 @@ +// +// 2002-2005 AlphaSierraPapa +// GNU General Public License +// +// $Revision$ +// + +using System; + +namespace DebuggerLibrary.Tests.TestPrograms +{ + public class SimpleProgram + { + public static void Main() + { + + } + } +} diff --git a/src/SharpDevelop.WithTests.sln b/src/SharpDevelop.WithTests.sln index f5e27fd201..7983ba7ca4 100644 --- a/src/SharpDevelop.WithTests.sln +++ b/src/SharpDevelop.WithTests.sln @@ -1,5 +1,5 @@ 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}" ProjectSection(SolutionItems) = postProject EndProjectSection @@ -36,6 +36,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Debugger", "Debugger", "{66 ProjectSection(SolutionItems) = postProject EndProjectSection 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}" EndProject 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 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Build.Tasks", "Libraries\ICSharpCode.Build.Tasks\Project\ICSharpCode.Build.Tasks.csproj", "{4139CCF6-FB49-4A9D-B2CF-331E9EA3198D}" 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}" EndProject 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} {1D18D788-F7EE-4585-A23B-34DC8EC63CB8} = {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} {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D} = {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} {870115DD-960A-4406-A6B9-600BCDC36A03} = {9421EDF4-9769-4BE9-B5A6-C87DE221D73C} {1152B71B-3C05-4598-B20D-823B5D40559E} = {5A3EBEBA-0560-41C1-966B-23F7D03A5486}