2
2
// Licensed under the MIT License.
3
3
4
4
using System ;
5
+ using System . Diagnostics ;
5
6
using System . IO ;
6
7
using System . Linq ;
7
8
using System . Runtime . InteropServices ;
11
12
using Microsoft . Extensions . Logging ;
12
13
using Microsoft . Extensions . Logging . Debug ;
13
14
using OmniSharp . Extensions . DebugAdapter . Client ;
15
+ using DapStackFrame = OmniSharp . Extensions . DebugAdapter . Protocol . Models . StackFrame ;
14
16
using OmniSharp . Extensions . DebugAdapter . Protocol . Events ;
15
17
using OmniSharp . Extensions . DebugAdapter . Protocol . Models ;
16
18
using OmniSharp . Extensions . DebugAdapter . Protocol . Requests ;
20
22
21
23
namespace PowerShellEditorServices . Test . E2E
22
24
{
25
+ public class XunitOutputTraceListener ( ITestOutputHelper output ) : TraceListener
26
+ {
27
+ public override void Write ( string message ) => output . WriteLine ( message ) ;
28
+ public override void WriteLine ( string message ) => output . WriteLine ( message ) ;
29
+ }
30
+
23
31
[ Trait ( "Category" , "DAP" ) ]
24
32
public class DebugAdapterProtocolMessageTests : IAsyncLifetime , IDisposable
25
33
{
@@ -38,13 +46,20 @@ public class DebugAdapterProtocolMessageTests : IAsyncLifetime, IDisposable
38
46
/// Completes when the first breakpoint is reached.
39
47
/// </summary>
40
48
public TaskCompletionSource < StoppedEvent > Stopped { get ; } = new TaskCompletionSource < StoppedEvent > ( ) ;
49
+
50
+ /// <summary>
51
+ /// Constructor. The ITestOutputHelper is injected by xUnit and used to write diagnostic logs.
52
+ /// </summary>
53
+ /// <param name="output"></param>
41
54
public DebugAdapterProtocolMessageTests ( ITestOutputHelper output ) => _output = output ;
42
55
43
56
public async Task InitializeAsync ( )
44
57
{
45
58
LoggerFactory debugLoggerFactory = new ( ) ;
46
59
debugLoggerFactory . AddProvider ( new DebugLoggerProvider ( ) ) ;
47
60
61
+ // NOTE: To see debug logger output, add this line to your test
62
+
48
63
_psesProcess = new PsesStdioProcess ( debugLoggerFactory , true ) ;
49
64
await _psesProcess . Start ( ) ;
50
65
@@ -308,7 +323,7 @@ await Assert.ThrowsAsync<JsonRpcException>(() => PsesDebugAdapterClient.RequestS
308
323
}
309
324
310
325
[ SkippableFact ]
311
- public async Task SendsInitialLabelBreakpointForPerformanceReasons ( )
326
+ public async Task SendsInitialLabelBreakpointForPerformanceReasons ( ITestOutputHelper output )
312
327
{
313
328
Skip . If ( PsesStdioProcess . RunningInConstrainedLanguageMode ,
314
329
"Breakpoints can't be set in Constrained Language Mode." ) ;
@@ -318,6 +333,9 @@ public async Task SendsInitialLabelBreakpointForPerformanceReasons()
318
333
"after breakpoint"
319
334
) ) ;
320
335
336
+ // Enables DAP messages to be written to the test output
337
+ Trace . Listeners . Add ( new XunitOutputTraceListener ( _output ) ) ;
338
+
321
339
//TODO: This is technically wrong per the spec, configDone should be completed BEFORE launching, but this is how the vscode client does it today and we really need to fix that.
322
340
await PsesDebugAdapterClient . LaunchScript ( filePath , Started ) ;
323
341
@@ -348,7 +366,7 @@ public async Task SendsInitialLabelBreakpointForPerformanceReasons()
348
366
StackTraceResponse stackTraceResponse = await PsesDebugAdapterClient . RequestStackTrace (
349
367
new StackTraceArguments { ThreadId = 1 }
350
368
) ;
351
- StackFrame firstFrame = stackTraceResponse . StackFrames . First ( ) ;
369
+ DapStackFrame firstFrame = stackTraceResponse . StackFrames . First ( ) ;
352
370
Assert . Equal (
353
371
firstFrame . PresentationHint ,
354
372
StackFramePresentationHint . Label
0 commit comments