22Test lldb-dap setBreakpoints request
33"""
44
5-
65import dap_server
76from lldbsuite .test .decorators import *
87from lldbsuite .test .lldbtest import *
@@ -398,7 +397,7 @@ def test_extra_launch_commands(self):
398397 # Verify all "preRunCommands" were found in console output
399398 self .verify_commands ("preRunCommands" , output , preRunCommands )
400399
401- # Verify all "launchCommands" were founc in console output
400+ # Verify all "launchCommands" were found in console output
402401 # After execution, program should launch
403402 self .verify_commands ("launchCommands" , output , launchCommands )
404403 # Verify the "stopCommands" here
@@ -420,6 +419,47 @@ def test_extra_launch_commands(self):
420419 output = self .get_console (timeout = 1.0 )
421420 self .verify_commands ("exitCommands" , output , exitCommands )
422421
422+ @skipIfWindows
423+ @skipIfRemote
424+ def test_failing_launch_commands (self ):
425+ """
426+ Tests "launchCommands" failures prevents a launch.
427+ """
428+ self .build_and_create_debug_adaptor ()
429+ program = self .getBuildArtifact ("a.out" )
430+
431+ # Run an invalid launch command, in this case a bad path.
432+ launchCommands = ['!target create "/bad/path%s"' % (program )]
433+
434+ initCommands = ["target list" , "platform list" ]
435+ preRunCommands = ["image list a.out" , "image dump sections a.out" ]
436+ response = self .launch (
437+ program ,
438+ initCommands = initCommands ,
439+ preRunCommands = preRunCommands ,
440+ launchCommands = launchCommands ,
441+ expectFailure = True ,
442+ )
443+
444+ self .assertFalse (response ["success" ])
445+ self .assertRegex (
446+ response ["message" ],
447+ r"Failed to run launch commands\. See the Debug Console for more details" ,
448+ )
449+
450+ # Get output from the console. This should contain both the
451+ # "initCommands" and the "preRunCommands".
452+ output = self .get_console ()
453+ # Verify all "initCommands" were found in console output
454+ self .verify_commands ("initCommands" , output , initCommands )
455+ # Verify all "preRunCommands" were found in console output
456+ self .verify_commands ("preRunCommands" , output , preRunCommands )
457+
458+ # Verify all "launchCommands" were founc in console output
459+ # The launch should fail due to the invalid command.
460+ self .verify_commands ("launchCommands" , output , launchCommands )
461+ self .assertRegex (output , r"unable to find executable for '/bad/path/" )
462+
423463 @skipIfWindows
424464 @skipIfNetBSD # Hangs on NetBSD as well
425465 @skipIf (archs = ["arm" , "aarch64" ], oslist = ["linux" ])
0 commit comments