1""" 2Test lldb-dap repl mode detection 3""" 4 5import lldbdap_testcase 6import dap_server 7from lldbsuite.test import lldbutil 8from lldbsuite.test.decorators import * 9from lldbsuite.test.lldbtest import * 10 11 12class TestDAP_repl_mode_detection(lldbdap_testcase.DAPTestCaseBase): 13 def assertEvaluate(self, expression, regex): 14 self.assertRegex( 15 self.dap_server.request_evaluate(expression, context="repl")["body"][ 16 "result" 17 ], 18 regex, 19 ) 20 21 def test_completions(self): 22 program = self.getBuildArtifact("a.out") 23 self.build_and_launch(program) 24 25 source = "main.cpp" 26 breakpoint1_line = line_number(source, "// breakpoint 1") 27 breakpoint2_line = line_number(source, "// breakpoint 2") 28 29 self.set_source_breakpoints(source, [breakpoint1_line, breakpoint2_line]) 30 31 self.assertEvaluate( 32 "`command regex user_command s/^$/platform/", r"\(lldb\) command regex" 33 ) 34 self.assertEvaluate( 35 "`command alias alias_command platform", r"\(lldb\) command alias" 36 ) 37 self.assertEvaluate( 38 "`command alias alias_command_with_arg platform select --sysroot %1 remote-linux", 39 r"\(lldb\) command alias", 40 ) 41 42 self.continue_to_next_stop() 43 self.assertEvaluate("user_command", "474747") 44 self.assertEvaluate("alias_command", "474747") 45 self.assertEvaluate("alias_command_with_arg", "474747") 46 self.assertEvaluate("platform", "474747") 47 48 self.continue_to_next_stop() 49 platform_help_needle = "Commands to manage and create platforms" 50 self.assertEvaluate("user_command", platform_help_needle) 51 self.assertEvaluate("alias_command", platform_help_needle) 52 self.assertEvaluate( 53 "alias_command_with_arg " + self.getBuildDir(), "Platform: remote-linux" 54 ) 55 self.assertEvaluate("platform", platform_help_needle) 56