|
26 | 26 |
|
27 | 27 | using System;
|
28 | 28 | using System.IO;
|
29 |
| -using System.Linq; |
30 | 29 | using System.Threading;
|
31 | 30 | using System.Reflection;
|
32 | 31 | using System.Collections.Generic;
|
33 | 32 |
|
34 | 33 | using Mono.Debugging.Soft;
|
35 | 34 | using Mono.Debugging.Client;
|
36 | 35 |
|
37 |
| -using MonoDevelop.Core; |
38 |
| -using MonoDevelop.Core.Execution; |
39 | 36 | using MonoDevelop.Projects.Text;
|
40 |
| -using MonoDevelop.Core.Assemblies; |
41 | 37 |
|
42 | 38 | using NUnit.Framework;
|
43 | 39 |
|
44 | 40 | namespace MonoDevelop.Debugger.Tests
|
45 | 41 | {
|
46 | 42 | [TestFixture]
|
47 |
| - public abstract class DebugTests |
| 43 | + public abstract partial class DebugTests |
48 | 44 | {
|
| 45 | + const string TestAppExeName = "MonoDevelop.Debugger.Tests.TestApp.exe"; |
| 46 | + const string TestAppProjectDirName = "MonoDevelop.Debugger.Tests.TestApp"; |
| 47 | + |
49 | 48 | readonly ManualResetEvent targetStoppedEvent = new ManualResetEvent (false);
|
50 | 49 | readonly string EngineId;
|
51 |
| - DebuggerEngine engine; |
52 | 50 | string TestName = "";
|
53 | 51 | TextFile SourceFile;
|
54 | 52 |
|
@@ -82,106 +80,57 @@ public void IgnoreSoftDebugger (string message = "")
|
82 | 80 | [TestFixtureSetUp]
|
83 | 81 | public virtual void SetUp ()
|
84 | 82 | {
|
85 |
| - foreach (var e in DebuggingService.GetDebuggerEngines ()) { |
86 |
| - if (e.Id == EngineId) { |
87 |
| - engine = e; |
88 |
| - break; |
89 |
| - } |
90 |
| - } |
91 |
| - if (engine == null) |
92 |
| - Assert.Ignore ("Engine not found: {0}", EngineId); |
| 83 | + SetUpPartial (); |
93 | 84 | }
|
94 | 85 |
|
| 86 | + partial void SetUpPartial(); |
| 87 | + |
| 88 | + |
95 | 89 | [TestFixtureTearDown]
|
96 | 90 | public virtual void TearDown ()
|
97 | 91 | {
|
| 92 | + TearDownPartial (); |
98 | 93 | if (Session != null) {
|
99 | 94 | Session.Exit ();
|
100 | 95 | Session.Dispose ();
|
101 | 96 | Session = null;
|
102 | 97 | }
|
103 | 98 | }
|
104 | 99 |
|
105 |
| - protected void Start (string test) |
106 |
| - { |
107 |
| - TargetRuntime runtime; |
| 100 | + partial void TearDownPartial (); |
108 | 101 |
|
109 |
| - switch (EngineId) { |
110 |
| - case "MonoDevelop.Debugger.Win32": |
111 |
| - runtime = Runtime.SystemAssemblyService.GetTargetRuntime ("MS.NET"); |
112 |
| - break; |
113 |
| - case "Mono.Debugger.Soft": |
114 |
| - runtime = Runtime.SystemAssemblyService.GetTargetRuntimes () |
115 |
| - .OfType<MonoTargetRuntime> () |
116 |
| - .OrderByDescending ((o) => { |
117 |
| - //Attempt to find latest version of Mono registred in IDE and use that for unit tests |
118 |
| - if (string.IsNullOrWhiteSpace (o.Version) || o.Version == "Unknown") |
119 |
| - return new Version (0, 0, 0, 0); |
120 |
| - int indexOfBeforeDetails = o.Version.IndexOf (" (", StringComparison.Ordinal); |
121 |
| - if (indexOfBeforeDetails == -1) |
122 |
| - return new Version (0, 0, 0, 0); |
123 |
| - string hopefullyVersion = o.Version.Remove (indexOfBeforeDetails); |
124 |
| - Version version; |
125 |
| - if (Version.TryParse (hopefullyVersion, out version)) { |
126 |
| - return version; |
127 |
| - } else { |
128 |
| - return new Version (0, 0, 0, 0); |
129 |
| - } |
130 |
| - }).FirstOrDefault (); |
131 |
| - break; |
132 |
| - default: |
133 |
| - runtime = Runtime.SystemAssemblyService.DefaultRuntime; |
134 |
| - break; |
135 |
| - } |
136 |
| - |
137 |
| - if (runtime == null) { |
138 |
| - Assert.Ignore ("Runtime not found for: {0}", EngineId); |
139 |
| - return; |
| 102 | + protected string TargetExePath |
| 103 | + { |
| 104 | + get{ |
| 105 | + return Path.Combine (TargetExeDirectory, TestAppExeName); |
140 | 106 | }
|
| 107 | + } |
141 | 108 |
|
142 |
| - Console.WriteLine ("Target Runtime: " + runtime.DisplayRuntimeName + " " + runtime.Version + " " + (IntPtr.Size == 8 ? "64bit" : "32bit")); |
143 |
| - |
144 |
| - // main/build/tests |
145 |
| - FilePath path = Path.GetDirectoryName (GetType ().Assembly.Location); |
146 |
| - var exe = Path.Combine (path, "MonoDevelop.Debugger.Tests.TestApp.exe"); |
147 |
| - |
148 |
| - var cmd = new DotNetExecutionCommand (); |
149 |
| - cmd.TargetRuntime = runtime; |
150 |
| - cmd.Command = exe; |
151 |
| - cmd.Arguments = test; |
152 |
| - |
153 |
| - if (Platform.IsWindows) { |
154 |
| - var monoRuntime = runtime as MonoTargetRuntime; |
155 |
| - if (monoRuntime != null) { |
156 |
| - var psi = new System.Diagnostics.ProcessStartInfo (Path.Combine (monoRuntime.Prefix, "bin", "pdb2mdb.bat"), cmd.Command); |
157 |
| - psi.UseShellExecute = false; |
158 |
| - psi.CreateNoWindow = true; |
159 |
| - System.Diagnostics.Process.Start (psi).WaitForExit (); |
160 |
| - } |
161 |
| - } |
| 109 | + protected void Start (string test) |
| 110 | + { |
| 111 | + TestName = test; |
| 112 | + Session = CreateSession (test); |
162 | 113 |
|
163 |
| - var dsi = engine.CreateDebuggerStartInfo (cmd); |
| 114 | + var dsi = CreateStartInfo (test); |
164 | 115 | var soft = dsi as SoftDebuggerStartInfo;
|
165 | 116 |
|
166 | 117 | if (soft != null) {
|
167 |
| - var assemblyName = AssemblyName.GetAssemblyName (exe); |
| 118 | + var assemblyName = AssemblyName.GetAssemblyName (TargetExePath); |
168 | 119 |
|
169 |
| - soft.UserAssemblyNames = new List<AssemblyName> (); |
170 |
| - soft.UserAssemblyNames.Add (assemblyName); |
| 120 | + soft.UserAssemblyNames = new List<AssemblyName> {assemblyName}; |
171 | 121 | }
|
172 |
| - |
173 |
| - Session = engine.CreateSession (); |
174 |
| - var ops = new DebuggerSessionOptions (); |
175 |
| - ops.ProjectAssembliesOnly = true; |
176 |
| - ops.EvaluationOptions = EvaluationOptions.DefaultOptions; |
| 122 | + var ops = new DebuggerSessionOptions { |
| 123 | + ProjectAssembliesOnly = true, |
| 124 | + EvaluationOptions = EvaluationOptions.DefaultOptions |
| 125 | + }; |
177 | 126 | ops.EvaluationOptions.AllowTargetInvoke = AllowTargetInvokes;
|
178 | 127 | ops.EvaluationOptions.EvaluationTimeout = 100000;
|
179 | 128 |
|
180 |
| - path = path.ParentDirectory.ParentDirectory.Combine ("src", "addins", "MonoDevelop.Debugger", "MonoDevelop.Debugger.Tests.TestApp", test + ".cs").FullPath; |
181 |
| - SourceFile = TextFile.ReadFile (path); |
182 |
| - TestName = test; |
| 129 | + |
| 130 | + var sourcePath = Path.Combine (TargetProjectSourceDir, test + ".cs"); |
| 131 | + SourceFile = TextFile.ReadFile (sourcePath); |
183 | 132 | AddBreakpoint ("break");
|
184 |
| - |
| 133 | + |
185 | 134 | var done = new ManualResetEvent (false);
|
186 | 135 |
|
187 | 136 | Session.TargetHitBreakpoint += (sender, e) => {
|
|
0 commit comments