@@ -12,7 +12,7 @@ import * as platform from "../../src/platform";
12
12
import { IPlatformDetails } from "../../src/platform" ;
13
13
import { IEditorServicesSessionDetails , IPowerShellVersionDetails , SessionManager , SessionStatus } from "../../src/session" ;
14
14
import * as utils from "../../src/utils" ;
15
- import { BuildBinaryModuleMock , InstallCSharpExtension , ensureEditorServicesIsConnected , stubInterface , testLogger } from "../utils" ;
15
+ import { BuildBinaryModuleMock , InstallCSharpExtension , WaitEvent , ensureEditorServicesIsConnected , stubInterface , testLogger } from "../utils" ;
16
16
17
17
const TEST_NUMBER = 7357 ; //7357 = TEST. Get it? :)
18
18
@@ -408,6 +408,7 @@ describe("DebugSessionFeature E2E", function slowTests() {
408
408
let stopDebugSession : DebugSession ;
409
409
const interactiveSessionConfig = defaultDebugConfigurations [ DebugConfig . InteractiveSession ] ;
410
410
// Asserts dont seem to fire in this event or the event doesnt resolve in the test code flow, so we need to "extract" the values for later use by the asserts
411
+
411
412
const startDebugEvent = debug . onDidStartDebugSession ( ( newDebugSession ) => {
412
413
startDebugEvent . dispose ( ) ;
413
414
startDebugSession = newDebugSession ;
@@ -469,37 +470,32 @@ describe("DebugSessionFeature E2E", function slowTests() {
469
470
const cmdletSourcePath = Uri . joinPath ( workspace . workspaceFolders ! [ 0 ] . uri , "mocks/BinaryModule/TestSampleCmdletCommand.cs" ) ;
470
471
const testScriptDocument = await workspace . openTextDocument ( testScriptPath ) ;
471
472
await window . showTextDocument ( testScriptDocument ) ;
473
+
474
+ // We cant see when a breakpoint is hit because the code we would spy on is in the C# extension or is vscode private, but we can see if the debug session changes which should only happen when the debug session context switches to C#, so that's good enough.
475
+
476
+ //We wire this up before starting the debug session so the event is registered
477
+ const dotnetDebugSessionActive = WaitEvent ( debug . onDidChangeActiveDebugSession , ( session ) => {
478
+ console . log ( `Debug Session Changed: ${ session ?. name } ` ) ;
479
+ return ! ! session ?. name . match ( / D o t n e t D e b u g g e r / ) ;
480
+ } ) ;
481
+
472
482
// Break at beginProcessing of the cmdlet
473
483
debug . addBreakpoints ( [
474
484
new SourceBreakpoint ( {
475
485
uri : cmdletSourcePath ,
476
486
range : new Range ( 26 , 0 , 26 , 0 ) //BeginProcessing
477
- } )
487
+ } , true , undefined , undefined , "TEST-BinaryModuleBreakpoint" )
478
488
] ) ;
479
- // HACK: Could not find a way to detect a breakpoint hit directly, but we can detect if the editor view changes to our breakpointed file.
480
- let editorChanged : ( ) => void ;
481
- let activeEditorChangedToCmdletSourcePath = false ;
482
- const waitForEditorChange = async ( ) => {
483
- return new Promise < void > ( ( resolve ) => { editorChanged = resolve ; } ) ;
484
- } ;
485
- const activeEditorChanged = window . onDidChangeActiveTextEditor ( ( editor ) => {
486
- console . log ( `Active editor changed to ${ editor ?. document . uri . path } ` ) ;
487
- if ( editor ?. document . uri . path == cmdletSourcePath . path ) {
488
- activeEditorChanged . dispose ( ) ;
489
- activeEditorChangedToCmdletSourcePath = true ;
490
- editorChanged ( ) ;
491
- } else {
492
- console . log ( `${ editor ?. document . uri . path } doesn't match ${ cmdletSourcePath . path } ` ) ;
493
- }
494
- } ) ;
489
+
495
490
const debugStarted = await debug . startDebugging ( undefined , launchScriptConfig ) ;
496
491
console . log ( debug . breakpoints ) ;
497
- console . log ( "Waiting for editor change" ) ;
498
- await waitForEditorChange ( ) ;
492
+ const dotnetDebugSession = await dotnetDebugSessionActive ;
493
+ console . log ( debug . activeDebugSession ) ;
494
+ console . log ( debug . breakpoints ) ;
499
495
const debugStopped = await debug . stopDebugging ( undefined ) ;
500
496
501
497
assert . ok ( debugStarted ) ;
502
- assert . ok ( activeEditorChangedToCmdletSourcePath ) ;
498
+ assert . ok ( dotnetDebugSession ) ;
503
499
assert . ok ( debugStopped ) ;
504
500
} ) ;
505
501
} ) ;
0 commit comments